fix(account-pool): isolate upstream connections from shared HTTP/2 sessions - #3203
Open
hemaaanth wants to merge 2 commits into
Open
fix(account-pool): isolate upstream connections from shared HTTP/2 sessions#3203hemaaanth wants to merge 2 commits into
hemaaanth wants to merge 2 commits into
Conversation
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.
Human comments
What was wrong
Account Pooler used the process-wide fetch dispatcher for upstream requests. In #3201, a cached upstream HTTP/2 session was destroyed but continued failing requests immediately with
TypeError: fetch failed, caused byThe session has been destroyed(ERR_HTTP2_INVALID_SESSION). This was observed for both the Anthropic (api.anthropic.com) and ChatGPT/Codex (chatgpt.com) origins on the same host: whichever origin's cached session was destroyed failed every request to it, while the other origin could remain healthy. Clearing the affected origin's cached pool restored a real pooled request. The hub discarded the fetch cause, leaving only a generic 502 and obscuring the transport failure. The event that originally destroyed the session remains unknown.What changed
Give Account Pooler an owned
EnvHttpProxyAgentwith HTTP/2 disabled, covering proxied inference, token refresh, usage requests, and OAuth login. Because this transport is used for every upstream, the fix applies uniformly to all providers (Claude and ChatGPT/Codex), for both the plain HTTP path and the Codex realtime path, which forwards its upstream leg through the same hub transport. It honors proxy environment variables and avoids reuse of the process-wide HTTP/2 pool. Disposal waits for the hub's existing request-drain window before destroying connections. No request retries are added.Retain the original fetch cause internally and log only a recognized transport error code, without raw error messages or credentials. Document the transport behavior in
PLUGIN_OVERVIEW.md. There are no CLI or server/daemon wire changes.Trade-offs
How you verified
pnpm exec turbo run test typecheck --filter=bb-plugin-account-pool: 261 tests passed across 10 files; typecheck passed.pnpm exec turbo run build --filter=@bb/server: passed. Scoped Oxlint andgit diff --checkpassed.h2/2.0, as expected. The natural session-destruction trigger remains unknown.https://api.anthropic.comandhttps://chatgpt.com, each returning the expected HTTP 401 rather than the destroyed-session error, confirming the fix covers both providers. The installed BB runtime was not replaced with this build.Fixes #3201