Skip to content

fix(sse): serve the stored 429 instead of re-sending refused requests - #14588

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
maxmad64bis:fix/opencode-proxy-dedup-per-request
Sep 24, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.8.51from
maxmad64bis:fix/opencode-proxy-dedup-per-request

Conversation

@maxmad64bis

@maxmad64bis maxmad64bis commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ base-red inherited: #14547

Summary

A 429 that names a real rate limit used to be served again on the next leg of the same wave: each leg re-offered the same refused route, so one refusal could surface as several identical 429s. The wave now serves the stored 429 directly instead of re-sending a request the provider already refused. Scope: the attempt loop only; the opt-in park-and-replay path (OPENCODE_PARK_AND_RESUME, default off) runs outside the loop and is out of scope. When every route is refused, the stored 429 is served as-is (no extra call).

Why this has no flag, unlike the early stop you gated in #13657: that rework keeps every opencode 429 moving to the next account (#9611), and so does this. The request still tries every other route. What changes is that it no longer re-sends through a proxy route that just returned 429 for this same request: the provider answers per egress address (#9611), so another account behind that route gets the same 429. When nothing else is left, the client gets that real upstream 429 untouched, the same contract as your #13657 rework. The only calls removed are ones that couldn't succeed, which also spares the provider a burst of identical refused requests.

Related Issues

Validation

  • Change type: routing
  • Focused tests and category gates from the golden path
  • npm run lint — ESLint on the touched files is clean (exit 0 with repo suppressions); the full run is red on the base (🔴 Release branch not green: release/v3.8.51 #14547 — cliproxyAccountHealth.ts TS2322, file outside this diff, identical on base)
  • Reconciled with the current active release base (18bbb101, focused checks rerun afterward: file-size green, complexity 0, eslint 0, unit 3/3 + neighbors 22/22)
  • Production-code changes include a new or updated automated test in this PR

Tests Added Or Updated

  • tests/unit/opencode-429-proxy-dedup.test.ts (new, 3 tests): refused route served once instead of re-sent (2 accounts/1 route → 1 call), all-refused fail-open (stored 429 served, no extra call), same-host distinct-port untouched (2 calls, 200 served). Park + early-stop flags unset during tests, restored after.
  • Neighbors rerun, no regression: opencode-429-park-resume.test.ts 8/8, opencode-transient-rotation.test.ts 11/11, opencode-accounts-per-request.test.ts 5/5.

Coverage Notes

  • Touches open-sse/executors/opencode.ts only (+ test): the 3 new cases cover the stored-429 path (write, read, guard). No coverage moved down in any touched file.

Reviewer Notes

@maxmad64bis
maxmad64bis force-pushed the fix/opencode-proxy-dedup-per-request branch 2 times, most recently from 0ea3d9a to 3619004 Compare September 23, 2026 08:16
@maxmad64bis
maxmad64bis marked this pull request as ready for review September 23, 2026 08:16
@maxmad64bis
maxmad64bis force-pushed the fix/opencode-proxy-dedup-per-request branch from 3619004 to 1a8c367 Compare September 23, 2026 08:40
@maxmad64bis maxmad64bis changed the title fix(sse): skip already-429 proxies within one rotation wave fix(sse): serve the stored 429 instead of re-sending refused requests Sep 23, 2026
@diegosouzapw

Copy link
Copy Markdown
Owner

Nice, targeted fix — avoiding a re-send through a proxy route that the provider just refused
with a real rate-limit 429 (instead of burning another call that can't succeed) is a clear
win, and the scope cut (attempt loop only, park-and-replay explicitly excluded) is exactly
right. The dedup test spins up real TCP listeners and drives the executor end-to-end rather
than mocking around it — good coverage. Only note: you also have #14659 open in the same
area (pool re-selection after a per-address 429) — worth a quick cross-check before both land
to make sure they don't step on each other.

@diegosouzapw
diegosouzapw merged commit ccb1012 into diegosouzapw:release/v3.8.51 Sep 24, 2026
9 of 16 checks passed
@maxmad64bis
maxmad64bis deleted the fix/opencode-proxy-dedup-per-request branch September 24, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants