Repository navigation
fix(chutes): cancel userinfo error response body before returning null - #109677
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 1:45 AM ET / 05:45 UTC. Summary PR surface: Source +2, Tests +41. Total +43 across 2 files. Reproducibility: no. high-confidence real HTTP reproduction is supplied. Current source and the constructed-stream regression clearly expose the unread-body path, but a loopback or live stalled response is still needed to verify transport cleanup. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Keep the owner-local cancellation and regression test, then add redacted loopback HTTP proof showing that a stalled non-2xx userinfo response closes promptly while login still returns the issued credentials without profile enrichment. Do we have a high-confidence way to reproduce the issue? No high-confidence real HTTP reproduction is supplied. Current source and the constructed-stream regression clearly expose the unread-body path, but a loopback or live stalled response is still needed to verify transport cleanup. Is this the best way to solve the issue? Yes, the inline cancellation is the narrowest maintainable fix because the bundled plugin owns this code and cannot import core internals; merge readiness still depends on real HTTP proof rather than another implementation change. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 630b16805c3f. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +2, Tests +41. Total +43 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Merged via squash.
|
What Problem This Solves
The bundled Chutes OAuth plugin leaks an HTTP connection every time the userinfo probe returns a non-2xx response.
fetchChutesUserInfo(extensions/chutes/oauth.ts:131) didif (!response.ok) { return null; }without consuming or cancellingresponse.body, so the underlying connection stays attached until the server's idle timeout reaps it. The userinfo probe runs on every login / token exchange and fails in normal operation (IdP throttling, transient 5xx, or tokens without profile scope), so repeated login or probe attempts accumulate half-open connections.The core helper copy (
src/agents/chutes-oauth.ts) received exactly this fix in 6467c19 ("fix(chutes): cancel userinfo error bodies"), but the extension copy — the file the bundled plugin actually loads viaextensions/chutes/index.ts:16— was left behind. This PR ports the same cancel to the extension sibling.Why This Change Was Made
Adds
await response.body?.cancel().catch(() => undefined);beforereturn nullon the non-ok userinfo path. Cancelling the unread body releases the connection immediately instead of waiting for idle timeout, and the.catch(() => undefined)keeps a broken stream from changing the established "failed userinfo resolves to null" contract.This mirrors the merged error-body cancel pattern from #109196 (reef guard denial), #109071 (GitHub Copilot catalog error streams), and #109007 (Telegram getChat), and matches the core sibling fix 6467c19. No new abstraction: the plugin SDK exposes no shared cancel helper, each fixed surface keeps the same inline one-liner, and extensions cannot import
src/**internals.The other non-ok path in the same file — token exchange via
assertOkOrThrowProviderError(extensions/chutes/oauth.ts:172) — already consumes the error body through the bounded, redacted provider error reader (#97808, #103569), so it needs no change. Scope stays on the userinfo early return: 2 production lines.User Impact
null, and issued tokens are kept without profile enrichment.Evidence
Code path (source verified)
extensions/chutes/index.tsloginChutesfrom this fileextensions/chutes/oauth.tsexchangeChutesCodeForTokensawaitsfetchChutesUserInfo(optional enrichment; errors swallowed unless caller aborted)extensions/chutes/oauth.tsfetch(CHUTES_USERINFO_ENDPOINT)with bearer tokenextensions/chutes/oauth.tsreturn nullwith body unread → connection held until idle timeoutextensions/chutes/oauth.tsawait response.body?.cancel().catch(() => undefined)→return nullextensions/chutes/oauth.tsassertOkOrThrowProviderError, which reads the error body under the provider capRegression test — cancel observed through the production login flow
extensions/chutes/oauth.test.tsgains "cancels the userinfo error response body when profile lookup fails": the stubbed fetch returns a 200 token response, then a 503Responsewhose body is a realReadableStreamwith acancel()tracker. The test drives the production wrapperloginChutes→exchangeChutesCodeForTokens→fetchChutesUserInfoand asserts the stream was cancelled, while the issued credentials survive without email/accountId enrichment.Control-red
Same test against the unfixed source (the two production lines reverted):
Tests 1 failed | 6 skipped (7)— the new test fails atexpect(canceled).toBe(true)because nothing cancels the stream on the unfixed path. With the fix:Tests 7 passed (7).Test suite
Lint / typecheck / whitespace
What was not tested
ReadableStreambody, which exercises the sameresponse.body.cancel()path a wire response would.src/agents/chutes-oauth.tscopy — already fixed in 6467c19 with its own regression test; this PR only brings the extension sibling to parity.AI-assisted; reviewed before submission.