Repository navigation
fix(google): release a superseded retry response before waiting for a pacing slot - #8743
Conversation
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked. Hygiene✅ Deterministic PR hygiene checks passed. |
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Merge-manager review: correct — the superseded response is released before the pacing wait, the backoff sleeps without holding a slot, budget refusals still surface |
Codex Review Summary: ✅ CompletedThis 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. |
3beda4d to
b89c20d
Compare
|
Maintainer integration record (lane L3, 2026-11-19). Integrating exact head
|
Summary
With
requestPacing.maxConcurrentRequestson a Google provider, a retried request could wait on itself. When a send failed with a retryable status,fetchGoogleWithRetrykept the previous response open and then asked the pacer for a new slot. The backoff and the cancellation of the old response both ran inbeforeDispatch, which only runs after the slot is granted. With the cap saturated, the slot the retry was waiting for was held by its own previous response, so the turn stalled until a deadline fired. When a slot was free, the retry held the new slot through the whole backoff and blocked other requests.Example:
maxConcurrentRequests: 1, the first send returns 503. Before this change, the retry queues behind the slot owned by that 503 response and never dispatches. After it, the 503 body is cancelled (releasing its slot), the backoff runs holding no slot, and the retry then takes the free slot and dispatches.Changes:
src/adapters/physical-send.ts:createAdapterPhysicalSendgains an optionalbeforePacingcallback. It runs after the dispatch budget is reserved and beforewaitForPacing, followed by an abort check.beforeDispatchkeeps its post-admission meaning.src/adapters/google-http.ts: the retry preparation moves tobeforePacing. It cancels the previous response body first, then runs the abort-aware backoff. On a send-budget refusal the retained response is handed to the caller (Retry-After stays available) and the loop gives up ownership. Afinallycancels a response the loop still owns when the request is cancelled before the next send.structure/adapters/registry.md(new "Google retry lease ordering" section) and a pointer instructure/providers-and-adapters.md.No account, model, deadline, retry budget or concurrency limit changes.
Verification
New tests:
tests/adapters/google/google-retry-before-pacing.test.ts,tests/adapters/google/google-retry-held-lease.test.ts(saturated five-response case), and additions totests/adapters/physical-send.test.ts.dev(873ec9b): 7 failures, 4 of them 5-second timeouts showing the self-wait.Wider check through the repo runner (
bun scripts/test.ts, isolated home and--isolate) on all oftests/adapters/googleplustests/adapters/physical-send.test.ts: 1088 pass / 0 fail with this change, 1064 pass / 0 fail ondev. The 24 extra passes are the new tests (17 + 3 in the new files, 4 added tophysical-send.test.ts). The full suite was not run locally.Also passing:
bun check --no-script --noEmit(0 errors),scripts/structure-ssot.ts,scripts/privacy-scan.ts.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
Readiness boxes ticked by maintainer @lidge-jun at integration (2026-11-18) after the exact-head review and CI described in the PR comments.