Skip to content

Fetch retry on http releated errors#75

Open
novalisdenahi wants to merge 5 commits intomasterfrom
fetch-retry
Open

Fetch retry on http releated errors#75
novalisdenahi wants to merge 5 commits intomasterfrom
fetch-retry

Conversation

@novalisdenahi
Copy link
Copy Markdown
Contributor

Describe the purpose of your pull request

  • Implements logic to retry failed HTTP requests one time (on receiving unexpected status code, timeout or request error).

Related issues (only if applicable)

How to test? (only if applicable)

  • What part of the application was affected by the changes? What should be tested?

Security (only if applicable)

  • Describe any potential risks that could affect the component in terms of security.

Requirement checklist (only if applicable)

  • I have covered the applied changes with automated tests.
  • I have executed the full automated test set against my changes.
  • I have validated my changes against all supported platform versions.
  • I have read and accepted the contribution agreement.

@novalisdenahi novalisdenahi requested a review from a team as a code owner April 16, 2026 14:22
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
77.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
Contributor

@adams85 adams85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although it's an optional ticket, this will be a reference implementation, so it would be nice if you could implement it.

I suggest using the same messages as .NET SDK for consistency.

However, if you choose not to implement this, we should still add some auto-generated request ID to the debug log messages so the individual requests can be followed when reading the logs (think about situations where multiple SDK instances are running and writing logs to the same output.)

return this.getResponseAsync(eTag).thenComposeAsync(response -> {
if (response.shouldRetry()) {
try {
this.httpClient.connectionPool().evictAll();
Copy link
Copy Markdown
Contributor

@adams85 adams85 Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the specification in the ticket, we should only reset the connection pool if at least 30 seconds have passed since the last reset. (If there's been no reset yet, we should reset it immediately.)

This is to prevent socket exhaustion, which might otherwise be possible in extreme cases as, according to RFC 9293, TCP connection are kept around for some time in the TIME_WAIT state.

logger.error(logEventId, message, e);
}
future.complete(FetchResponse.failed(message, false, null));
future.complete(FetchResponse.failed(message, false, null, true));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you ensure that, just like in onResponse, future.complete is called even if logger.error throws an exception (which may be possible as it can execute user-provided code)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants