Repository navigation
fix(quota): enforce overall timeout for stalled fetch and body reads - #152
Conversation
pierreraby
left a comment
There was a problem hiding this comment.
Verified exact head 781255228eaf6c8b5cbdc00cc1b234eb70b5f398 (fork karaaslanz:fix/quota-timeout-upstream-20261013, base b61093d) as a scoped quota-timeout hardening change.
Independent checks on a clean detached checkout of this exact head:
npm run typecheckPASS; fullnpm run test:unitgreen (17 files, 0 failures, exit 0); quota suite 26/26 including the 3 new non-cooperative-I/O cases (~26 ms each, deterministic — no wall-clock upper bound asserted).- RED proven on base
b61093dwith the PR tests applied: the runner hangs on the first new test (killed by external timeout, exit 124) — the cooperative abort alone never settles a fetch that ignores the signal. prettier --checkandgit diff --checkPASS on both changed files.- Upstream checks on this head: 13/13 success (typecheck, format, CodeQL x2, Semgrep x2, OMP compat, npm audit, Gitleaks, lifecycle, dependency).
- Scope confirmed: only
src/quota.ts(+23/-8) andtests/test-quota.ts(+43); workflow files byte-identical to main.
Read of the fix: one shared deadline promise races fetchImpl(), error-body text(), and json(); the timer aborts before rejecting so signal.aborted normalizes every path to kind: "timeout" with the existing partial-quota fallback intact. All quota I/O (including the OMP usage provider via src/usage.ts) funnels through request()/safeRequest() — no uncovered I/O found.
Notes (non-blocking): no CHANGELOG entry (consistent with release-time collection per RELEASE.md — please credit #152 at release); the shared deadline promise's losing side stays pending for a broken custom fetch (real fetch honors the signal); no dedicated test for a stalled summaryRaw (same helper, covered by structure).
Approving. Leaving merge timing and 0.7.8 scoping to the maintainers.
Problem
The quota command enforces its overall timeout only by calling AbortController.abort(). A custom fetch implementation that ignores AbortSignal, or a response whose json()/text() never settles, leaves /commandcode-quota hanging past the configured deadline.
Fix
Verification
No changes to release/pricing, credentials or Control Center.