Skip to content

fix(quota): bound and log the active quota fetch path#52

Open
iceteaSA wants to merge 1 commit into
cortexkit:mainfrom
iceteaSA:fix/quota-active-path-resilience
Open

fix(quota): bound and log the active quota fetch path#52
iceteaSA wants to merge 1 commit into
cortexkit:mainfrom
iceteaSA:fix/quota-active-path-resilience

Conversation

@iceteaSA

@iceteaSA iceteaSA commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

The active quota path (boot seed, /openai-quota, reset preview → refreshAllQuotawhamUsageFn / token refresh) had no fetch timeout, no logging, and no failure surfacing. When the upstream API stalls, that renders as an indefinite "checking…" in the quota dialog, a silently-dead boot seed (.catch(() => {})), and zero log lines — indistinguishable from the plugin being broken. We hit exactly this in a live session: quota worked in the morning, froze for ~2h, then self-recovered with no code or config change. The WS header push kept working throughout (different socket), which is what pointed at the active path.

Changes:

  • AbortSignal.timeout(15s) on the wham/usage fetch and the token-refresh fetch (core/provider.ts). The refresh lock/lease is released in finally, so a timed-out refresh cannot strand a held lease.
  • AbortError/TimeoutError classified transient (core/backoff.ts) so a timeout gets the short retry backoff, not the long non-transient delay.
  • Structured start/success/failure logging on the quota channel (provider.ts, refresh-all-quota.ts), and the boot-seed catch now logs a warning instead of swallowing.
  • The quota dialog shows fetch failed — Refresh to retry on failed accounts instead of "checking…" forever (commands.ts).

All three parts are covered red-first (never-resolving fetch → bounded rejection; logger spies; dialog payload failure row). Gate: build, tsc, 680/680 tests, biome clean. Cross-family reviewed (M3 thinking): approve 0 must / 0 should — verified the lease-release-on-abort path, the transient classification of Bun's timeout error shape, and that the shared whamUsageFn doesn't conflict with the reset preview's own 60s bound.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Summary by cubic

Bounds and logs the active quota fetch path to avoid indefinite “checking…” when upstream stalls. Adds a 15s timeout, classifies timeouts as transient for quick retries, and shows a clear retry message in the quota dialog.

  • Bug Fixes
    • Added AbortSignal.timeout(15s) to whamUsageFn and codexRefreshFn requests.
    • Classified AbortError/TimeoutError as transient in backoff to use short retry delays.
    • Added structured start/success/failure logs on the quota channel; boot quota seed now logs warnings on failure.
    • Quota dialog now shows “- : fetch failed — Refresh to retry” instead of hanging on “checking…”.

Written for commit 698a301. Summary will update on new commits.

Review in cubic

Bound stalled quota and token-refresh requests so transient upstream hangs resolve into retryable failures. Log active-path failures and replace eternal checking rows with a short retry state.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Re-trigger cubic

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.

1 participant