You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(usage): reject a pre-cancelled quota wait before returning a cached result #733
The shared /usage cancellation boundary can return a fulfilled result after its AbortSignal is already cancelled. waitForUsage() registers both the supplied promise and its cancellation rejection in Promise.race() without checking a pre-aborted signal first, so an already-resolved credential or quota promise wins the race.
Reproduction
On origin/maina18f457687b45c877bc8a15d689a7580c4f0659a, with Node 24.14.1:
It prints stale quota. A cancelled wait should reject with the cancellation reason and must not make a prior result observable through this helper.
Scope
Add an entry guard to preserve cancellation precedence, and cover both a pre-cancelled fulfilled promise and the existing in-flight cancellation behavior. This does not abort or take ownership of Pi credential refresh; it only prevents the caller from observing a result after cancellation.
Deduplication
I checked open/closed Issues and PRs for usage cancel, AbortSignal, and usage-provider cancellation. Existing cancellation work covers provider request abort/fallback, not waitForUsage admitting a pre-cancelled fulfilled result.
I am claiming this narrow cancellation-boundary fix. I will add a deterministic regression, run the required checks, and open a separate PR from a fresh origin/main worktree.
Activity
outlier27-cell commentedon Oct 11, 2026
I am claiming this narrow cancellation-boundary fix. I will add a deterministic regression, run the required checks, and open a separate PR from a fresh origin/main worktree.