Skip to content

Run retry and completion handling for transport failures - #1475

Merged
mtdowling merged 2 commits into
mainfrom
fix-transport-error-attempt-lifecycle
Nov 30, 2026
Merged

mtdowling merged 2 commits into
mainfrom
fix-transport-error-attempt-lifecycle

Conversation

@mtdowling

Copy link
Copy Markdown
Member

Problem

When transport.send threw (connection refused, read timeout, reset, TLS failure, etc.), ClientPipeline remapped the exception and rethrew it directly. That skipped the rest of the attempt and execution lifecycle:

  • modifyBeforeAttemptCompletion / readAfterAttempt
  • RetryStrategy.refreshRetryToken, so the strategy was never consulted
  • modifyBeforeCompletion / readAfterExecution, so interceptors never observed the failure

Error responses already went through all of these; only transport failures bypassed them. A side effect is that ConnectionAcquireTimeoutException, which already reports RetrySafety.YES, could never actually be retried.

Changes

  1. Route transport failures through attempt completion. The post-deserialization half of deserialize() is extracted into completeAttempt(). A send failure builds an OutputHook with no response or output and calls completeAttempt(), so the completion hooks run, retry-info interceptors (e.g. ApplyModelRetryInfoPlugin) can classify the error, and the retry strategy decides whether to retry. Response-only hooks (readAfterTransmit through readAfterDeserialization) are skipped since there is no response. Deserialize-path exception remapping is unchanged.
  2. Treat connect failures as retry-safe. ConnectTimeoutException (from ConnectException or HttpConnectTimeoutException) means no connection was established, so the request never reached the service. Its Javadoc already said it is always retryable, but isRetrySafe() returned NO. It now returns YES.

Other transport exceptions (read timeouts, resets, etc.) still report NO; whether to retry those for idempotent operations is left for a follow-up.

Testing

New ClientPipelineTest cases (each fails without its corresponding change):

  • A socket timeout followed by a 200 is retried, the strategy receives TransportSocketTimeout, and the full hook sequence is asserted.
  • A non-retried connect failure runs all four completion hooks and surfaces ConnectTimeoutException.
  • StandardRetryStrategy retries a connect failure on a non-idempotent operation.

Ran :client:client-core:check and the tests for client-http, dynamic-client, aws-client-core, aws-client-restjson, and retries.

Transport exceptions were remapped and rethrown directly from the send
step, skipping modifyBeforeAttemptCompletion, readAfterAttempt, retry
token refresh, modifyBeforeCompletion, and readAfterExecution. Route
transport failures through the same attempt-completion path used for
error responses so interceptors observe them and the retry strategy
decides whether to retry.
ConnectTimeoutException is raised when a connection could not be
established, so the request never reached the service. Its Javadoc
already documents it as always retryable, but isRetrySafe() returned
NO, so the standard retry strategy refused to retry it. Return YES.
@mtdowling
mtdowling merged commit a94785c into main Nov 30, 2026
7 checks passed
@mtdowling
mtdowling deleted the fix-transport-error-attempt-lifecycle branch November 30, 2026 20:06
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