fix(quota): bound and log the active quota fetch path#52
Open
iceteaSA wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The active quota path (boot seed,
/openai-quota, reset preview →refreshAllQuota→whamUsageFn/ 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 infinally, so a timed-out refresh cannot strand a held lease.AbortError/TimeoutErrorclassified transient (core/backoff.ts) so a timeout gets the short retry backoff, not the long non-transient delay.provider.ts,refresh-all-quota.ts), and the boot-seed catch now logs a warning instead of swallowing.fetch failed — Refresh to retryon 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
whamUsageFndoesn't conflict with the reset preview's own 60s bound.Need help on this PR? Tag
/codesmithwith 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.
AbortSignal.timeout(15s)towhamUsageFnandcodexRefreshFnrequests.AbortError/TimeoutErroras transient in backoff to use short retry delays.quotachannel; boot quota seed now logs warnings on failure.Written for commit 698a301. Summary will update on new commits.