Repository navigation
Conversation
The shared proxy client keeps httpx's default limit of 100 connections, and streamed responses hold theirs until they finish. Once all of them are busy, a new proxied request waits for the client timeout and then raises httpx.PoolTimeout, which none of the backend failure handlers catches, so the client got a 500 that looks like a server bug. Map it to 503 PROXY_POOL_EXHAUSTED: the server is out of capacity, and the sandbox itself was never reached.
acodercat
requested review from
Generalwin,
Pangjiping,
hittyt,
jwx0925 and
ninan-nn
as code owners
October 31, 2026 08:41
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
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.
#2084 mapped proxied backend failures to gateway statuses (502
BACKEND_CONNECTION_FAILED, 504BACKEND_TIMEOUT, 502BACKEND_RESPONSE_FAILED), so that a sandbox problem no longer looks like a server bug. One timeout was left out:httpx.PoolTimeout.The proxy shares one
httpx.AsyncClient(timeout=180.0), which keeps httpx's default limit of 100 connections. A streamed response (an SSE stream, a long poll, a large download) holds its connection until it finishes. Once all of them are busy, the next proxied request waits 180 seconds for a free connection and then raisesPoolTimeout. That isn't caught by any of the backend handlers, so it ends in the generic handler and the client gets500 GENERAL::UNKNOWN_ERROR, "An internal error occurred in the proxy".Summary
httpx.PoolTimeoutnow returns 503 with codePROXY_POOL_EXHAUSTED. The server is out of capacity and the sandbox was never contacted, so 503 fits better than 504, and clients can retry.Testing
Not run (explain why)
Unit tests
Integration tests
e2e / manual verification
Added a
PoolTimeoutcase totest_proxy_maps_backend_failure_after_connect_to_gateway_error. It fails on current main with 500.The full server suite passes (2698 passed).
ruffandpyrightare clean.Breaking Changes
Checklist