pi-mono/packages
robopipi[bot] 90b42bca6e
fix(ai): remove Codex SSE retry abort listener after backoff (#11725)
The Codex Responses provider's local `sleep()` helper attached an
anonymous `abort` listener to the caller's signal and never removed it
when the timer fired. The SSE retry loop calls this helper before each
retry, so every completed backoff left one listener on the signal. Three
429 responses followed by a success left three listeners behind.

The helper now uses a named `onAbort` handler, removes it when the timer
fires, and registers it with `{ once: true }`. It still rejects with
`Error("Request was aborted")`, which the retry loop's catch block
depends on.

### Testing
- New regression test in `packages/ai/test/openai-codex-stream.test.ts`.
A stub fetch returns 429 with `retry-after: 0` three times and then a
completed SSE stream, using `maxRetries: 3` and the caller's own
`AbortController`. The test asserts that `getEventListeners(signal,
"abort")` is empty afterwards. It fails without the change ("got 3") and
passes with it.
- `node ../../node_modules/vitest/dist/cli.js --run
test/openai-codex-stream.test.ts`: 41/41 pass.
- A standalone script against the built package printed `listeners 3`
before the change and `listeners 0` after.
- `npm run check`: biome and the repo scripts pass. `tsc` fails, but
only in files this change does not touch: generated model ids in
`packages/ai` tests, `github-copilot.ts`, and missing bench dependencies
in `packages/schema`. I did not verify whether those failures also
happen on a clean checkout.

Fixes #11708

Requested by @badlogic

Co-authored-by: triagent <triagent@localhost>
2026-11-03 09:32:52 +01:00
..
agent Add [Unreleased] section for next cycle 2026-11-02 11:38:21 +01:00
ai fix(ai): remove Codex SSE retry abort listener after backoff (#11725) 2026-11-03 09:32:52 +01:00
chord fix(chord): int() table keys type as numbers again (a TypeBox leftover) 2026-11-03 08:32:07 +00:00
codemode Add [Unreleased] section for next cycle 2026-11-02 11:38:21 +01:00
coding-agent feat(chord): Chord v2 is the package's root 2026-11-02 22:36:55 +00:00
durable feat(chord): Chord v2 is the package's root 2026-11-02 22:36:55 +00:00
env feat(env): run programs with plain pipes through the daemon 2026-11-03 00:53:07 +01:00
evals Release v1.5.0 2026-11-02 11:38:21 +01:00
mcp fix(mcp): clean up server children on stdio close after the server exited (#11724) 2026-11-03 09:31:10 +01:00
schema Add [Unreleased] section for next cycle 2026-11-02 11:38:21 +01:00
telemetry Add [Unreleased] section for next cycle 2026-11-02 11:38:21 +01:00
tui Add [Unreleased] section for next cycle 2026-11-02 11:38:21 +01:00