Repository navigation
Conversation
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
|
Hey, just checking to see if this issue has been resolved or people just haven't gotten to it yet. |
|
Confirming this failure mode is still reproducible in production as of Sep 26, 2026 (opencode 1.3.3, controlled repro + production gap math posted on #17648). The delay cap in this PR is the highest-value first step — the no-headers cap is effectively dead for real 5xx responses since they always carry headers. One gap left even with this merged: the processor retry loop still has no attempt bound, so a persistent outage retries forever at the cap and never surfaces a terminal error. |
|
This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2. — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊 |
Issue for this PR
Closes #33728
Type of change
What does this PR do?
SessionRetry.delay()inpackages/opencode/src/session/retry.tsonly applied the 30-secondRETRY_MAX_DELAY_NO_HEADERScap in the no-headers branch (line 65). When a retryable error carried anyresponseHeadersobject — which real 502/503 responses almost always do, since they always sendcontent-type,date, etc. — but the headers did not include a parseableretry-after/retry-after-ms, the fallback path used uncapped exponential backoff bounded only byRETRY_MAX_DELAY(2,147,483,647 ms, the setTimeout limit).That meant a single flaky 5xx could grow the backoff to ~17 min by attempt 10, ~9 hours by attempt 15, and ~12 days by attempt 20. The 30 s cap was effectively dead in production because real responses always carry headers.
The fix applies the same
Math.min(..., RETRY_MAX_DELAY_NO_HEADERS)to the headers-branch fallback that the no-headers branch already uses. One-line change.How did you verify your code works?
packages/opencode/test/session/retry.test.ts:caps delay at 30 seconds when headers present but lack retry-after— runs 10 attempts with{ "content-type": "application/json" }and asserts the same[2000, 4000, 8000, 16000, 30000, 30000, 30000, 30000, 30000, 30000]shape the no-headers test already expects.caps delay at 30 seconds when retry-after header is unparseable—delay(8, ...)with{ "retry-after": "not-a-number" }returns30000(was returning256000before the fix).bun test test/session/retry.test.tsfrompackages/opencode→ 35 pass / 0 fail.bun run typecheckfrompackages/opencode→ clean.Screenshots / recordings
N/A — no UI changes.
Checklist