Skip to content

fix: respect the SDK retry budget for pooled HTTP requests - #588

Open
pcbeingused33 wants to merge 2 commits into
workos:mainfrom
pcbeingused33:fix/c7618-net-http-retries
Open

pcbeingused33 wants to merge 2 commits into
workos:mainfrom
pcbeingused33:fix/c7618-net-http-retries

Conversation

@pcbeingused33

Copy link
Copy Markdown

Description

When a server closes the connection before sending an HTTP response, Net::HTTP can resend a GET before BaseClient handles the EOF. This can exceed the SDK's retry budget, including when max_retries is zero.

Disable Net::HTTP retries when opening a pooled connection so that BaseClient controls the retry budget.

The regression tests use a local TCP server that closes each connection after reading the GET and responds with HTTP 200 if it receives an extra request. They verify that the client raises APIConnectionError after sending one GET with zero retries and two GETs with one retry.

bundle exec ruby -Itest test/workos/test_base_client.rb

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

No docs changes: this only changes how the SDK's HTTP connection pool retries.

AI assistance was used to prepare the patch and regression tests.

@pcbeingused33
pcbeingused33 requested a review from a team as a code owner November 30, 2026 20:00
@greptile-apps

greptile-apps Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; the previous SSL retry issue is fixed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous SSL retry issue is fixed.

Summary

The PR makes BaseClient control the retry budget for pooled HTTP requests.

  • Pooled requests follow the SDK retry limit exactly.
  • SSL and socket errors can use the SDK retry budget.

The previous finding is fixed. No new actionable issues were found. Tests were inspected but not run.

Reviews (2) · Last reviewed commit: "fix: retry TLS and socket errors within ..." · Reviewed by Greptile

Comment thread lib/workos/base_client.rb Resolved
@gjtorikian

Copy link
Copy Markdown
Contributor

The Greptile finding is correct. It must be fixed before the merge.

http.max_retries = 0 also removes the only retry for OpenSSL::SSL::SSLError, Errno::ECONNABORTED, and Errno::ETIMEDOUT on GET, PUT, and DELETE requests. execute_request does not rescue these errors.

I tested the SSLError case with max_retries: 2 and a GET request that gets one OpenSSL::SSL::SSLError:

  • On main, the request returns 200.
  • On this branch, the caller gets the raw OpenSSL::SSL::SSLError.

Please add these three errors to the rescue list in execute_request (lib/workos/base_client.rb, line 212). Then the SDK retries them within its retry budget and raises WorkOS::APIConnectionError. Please also add a test for an SSLError followed by a successful response.

@pcbeingused33

Copy link
Copy Markdown
Author

Thanks for reproducing this. The follow-up adds OpenSSL::SSL::SSLError, Errno::ECONNABORTED, and Errno::ETIMEDOUT to the SDK retry handler. They now count against the SDK retry budget and surface as WorkOS::APIConnectionError if the budget runs out. The regression test checks that a GET retries once after an SSL error and returns the successful response. All 53 BaseClient tests pass.

AI assistance was used to prepare the patch and regression test.

This branch has not been deployed

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants