Fix RemoteDisconnected errors from stale pooled connections#409
Open
Fix RemoteDisconnected errors from stale pooled connections#409
Conversation
When the SDK reuses an HTTP connection that has been idle for ~60s, the server-side infrastructure (ALB / nginx) may have already closed it. urllib3 then raises RemoteDisconnected which was not retried or caught. - Add a default urllib3 Retry policy (3 retries with backoff) so stale connections are transparently re-established at the transport layer. - Catch MaxRetryError and ProtocolError in rest.py so exhausted retries surface as ApiException instead of raw urllib3 errors.
CoreyEWood
reviewed
Feb 25, 2026
Comment on lines
+221
to
+226
| except urllib3.exceptions.MaxRetryError as e: | ||
| msg = "{0}\n{1}".format(type(e).__name__, str(e)) | ||
| raise ApiException(status=0, reason=msg) | ||
| except urllib3.exceptions.ProtocolError as e: | ||
| msg = "{0}\n{1}".format(type(e).__name__, str(e)) | ||
| raise ApiException(status=0, reason=msg) |
Contributor
There was a problem hiding this comment.
Was this manually added? This is a generated file so these changes will be wiped out every time it's re-generated.
CoreyEWood
reviewed
Feb 25, 2026
| read=3, | ||
| redirect=3, | ||
| backoff_factor=0.2, | ||
| allowed_methods=None, # retry all HTTP methods including POST |
Contributor
There was a problem hiding this comment.
I'm concerned about retrying POST requests because that could lead to e.g. duplicate IQ submissions if the request makes it to the server but an error occurs when reading the response.
Contributor
|
Confirming this seems to have fixed my issue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
proxy_read_timeout= 60s) may have already closed it. urllib3 then raisesRemoteDisconnectedwhich was neither retried nor caught.Retrypolicy (total=3, with backoff) so stale connections are transparently re-established at the transport layer. Users can still override viahttp_transport_retries.MaxRetryErrorandProtocolErrorinrest.pyso that if retries exhaust, the error surfaces asApiExceptioninstead of a raw urllib3 exception.Reproducer
After a few successful submissions, the next one fails with:
Test plan
test_create_groundlight_with_retriespasses (explicithttp_transport_retriesstill honored)test_http_retries.py5xx retry tests pass (mock bypasses urllib3 Retry layer)RemoteDisconnectedcrashesMade with Cursor