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
Root cause: In src/providers/quota.ts, maybeFetchProviderQuota() wraps provider quota probes in ry { ... } catch { return null; }, but four async branches (etchChatGptForwardQuota, etchAnthropicQuota, etchKiroQuota, and
eader(...) for key-based vendor probes such as OpenRouter and DeepSeek) returned their promises without ^Gwait. When any of those probes threw a network error (e.g. ECONNRESET or ENOTFOUND), the rejected promise bypassed the catch block and rejected the Promise.all in etchProviderQuotaReports(), failing the entire GET /api/provider-quotas response.
Fix: Add ^Gwait to all four
eturn statements inside maybeFetchProviderQuota() so per-provider probe rejections are caught and normalized to
ull (preserving bounded last-good cached rows on transient failures and returning healthy providers' reports).
Tests: Added ests/providers/provider-quota-probe-isolation.test.ts (and registered it in scripts/test-layout/layout-providers.json and ests/fixtures/test-layout-expected.json) covering OpenRouter ECONNRESET, DeepSeek ENOTFOUND, last-good cache preservation on transient throws, all-failing probes, and etchProviderApiKeyQuotas isolation.
bun test tests/providers/provider-quota-probe-isolation.test.ts tests/providers/deepseek-quota-currency.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts — 40 pass, 0 fail
bun test tests/providers/provider-quota.test.ts — 171 pass, 0 fail
bun run typecheck — no type errors in 2,645 files
bun run structure:check — passed
Checklist
Scope stays focused and avoids unrelated cleanup.
Docs or release notes were updated when needed.
Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.
Summary by CodeRabbit
Bug Fixes
Provider quota results now wait for quota checks to finish before being returned. A failed check for one provider no longer prevents other providers’ quota results from being reported.
When a provider check fails temporarily, its most recent successful quota report is retained while results from other providers can still update. API-key quota fetch failures are reported as unavailable rather than interrupting the results.
Maintainer completion (lidge-jun)
I finished this draft for the fb-contrib-queue lane. d7fbf4cb45 merges current dev into the branch with a merge commit; there is no force push and no source change beyond the merge. Validation on d7fbf4cb45: provider-quota-probe-isolation, provider-quota and the layout/size guards: 214 pass, 0 fail. Fail-before (independent terra review): with the merge-base src/providers/quota.ts, the OpenRouter ECONNRESET and DeepSeek ENOTFOUND cases throw out of /api/provider-quotas. Security: the catch discards the thrown value without logging it; a synthetic error URL containing a key does not reach the response or the console. Full local suite: NOT RUN (resource exception); CI covers it.
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
No actionable comments were generated in the recent review.
Walkthrough
The quota reader now awaits selected vendor and API-key quota calls. Added tests cover transport failures, retained reports, all-probe failures, and API-key failure rows. The new test is registered in the provider layout mapping and expected fixture.
Changes: Provider quota probe handling
Layer / File(s)
Summary
Await quota reader calls src/providers/quota.ts
The ChatGPT-forward, configured Anthropic, Kiro, and key-quota reader calls are awaited before their results are returned.
Test probe failure outcomes tests/providers/provider-quota-probe-isolation.test.ts, scripts/test-layout/layout-providers.json, tests/fixtures/test-layout-expected.json
Tests cover OpenRouter and DeepSeek transport failures, retention of the last-good OpenRouter report while DeepSeek updates, an empty report list when all vendor probes fail, and an unavailable API-key row with a null quota. The test is added to the provider layout mapping and expected fixture.
This change prevents one vendor's network error from failing the whole provider quota report. Reports from healthy providers are returned, and tests cover the failure cases. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: thrown vendor quota probe errors are isolated so that /api/provider-quotas does not fail as a whole. The raw summary confirms the change to maybeFetchProviderQuota in …
Linked Issues check
[#8939] requires that one failing vendor quota probe does not fail GET /api/provider-quotas. The whole-PR diff (merge base 3bc34e6 to head d7fbf4c) changes only src/providers/quota.ts in source code. …
Out of Scope Changes check
The whole-PR source diff for src/providers/quota.ts contains only the four added await keywords inside maybeFetchProviderQuota(). These directly implement [#8939]. No other hunk exists in that file.…
Full details: Title check
Explanation
The title names the main change: thrown vendor quota probe errors are isolated so that /api/provider-quotas does not fail as a whole. The raw summary confirms the change to maybeFetchProviderQuota in src/providers/quota.ts, where four promise-returning branches now await their fetches so that rejections are caught per provider. The PR objectives describe the same goal, tied to issue #8939. The title is specific, uses the conventional fix(scope) form, and stays under typical length limits.
Full details: Linked Issues check
Explanation
[#8939] requires that one failing vendor quota probe does not fail GET /api/provider-quotas. The whole-PR diff (merge base 3bc34e6 to head d7fbf4c) changes only src/providers/quota.ts in source code. In maybeFetchProviderQuota(), four promise-returning branches now use return await: fetchChatGptForwardQuota (hunk @@ -123,12 +123,12 @@), fetchAnthropicQuota for configured Anthropic instances, fetchKiroQuota for kiro, and reader(name, { ...provider }) (hunk @@ -138,7 +138,7 @@). Before the change these returned unawaited promises, so a rejection bypassed the enclosing try/catch, which returns null. With the awaits, a thrown ECONNRESET or ENOTFOUND from a key-based probe becomes null for that provider only. Promise.all in fetchProviderQuotaReports therefore resolves with the healthy providers' reports. The issue accepts omission or an error/unknown marker for the failing provider, and null yields omission. The fetchProviderApiKeyQuotas path also goes through maybeFetchProviderQuota. The new test file tests/providers/provider-quota-probe-isolation.test.ts exists at head. I read it. It asserts OpenRouter ECONNRESET isolation, DeepSeek ENOTFOUND isolation, last-good cache preservation with a transient OpenRouter throw, all-probes-failing returning an empty list, and fetchProviderApiKeyQuotas returning one unavailable row with null quota. I did not run these tests. The reader-to-collectOwnedReport call path shown in the issue stack trace (src/providers/quota/report-cache.ts) was not re-read in this review. Confidence in the mechanism rests on the awaited return inside the try block and on the test assertions.
Full details: Out of Scope Changes check
Explanation
The whole-PR source diff for src/providers/quota.ts contains only the four added await keywords inside maybeFetchProviderQuota(). These directly implement [#8939]. No other hunk exists in that file. The supporting changes are scripts/test-layout/layout-providers.json and tests/fixtures/test-layout-expected.json, which register the new test file for the repository layout checks, and tests/providers/provider-quota-probe-isolation.test.ts, which covers the fix. The test file contents match the isolation objectives and contain no unrelated behavior. The merge with dev (head d7fbf4c, per the maintainer note) adds no source change beyond the merge in the reviewed diff. I did not read the two layout JSON files in this review. Their scope is inferred from the raw summary.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between 30fd494 and d7fbf4c.
Files selected for processing: 1
tests/fixtures/test-layout-expected.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
all PR quality gates passed; the review readiness checklist is complete.
Review readiness checklist
✅ Required local validation passed; commands, results, and any full-suite exception are documented.
✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
✅ I resolved all correct Codex and CodeRabbit findings.
✅ My PR is ready for review.
✅ 4/4 boxes ticked.
This pull request is already Ready for Review.
The review-ready label marks this PR as ready; review automation runs independently.
Maintainers: @lidge-jun@Ingwannu
Maintainer integration (lidge-jun, dev) on exact head d7fbf4cb4544083a4fcbb9f0493a7c85cf69fffb.
Independent review: terra reviewer (gpt-6.1-terra) APPROVE across rounds 1–3. Round 3 confirmed that the dev merge commit equals the automatic merge tree (no conflict-resolution edits). Fail-before: with the merge-base src/providers/quota.ts, the OpenRouter ECONNRESET and DeepSeek ENOTFOUND probes throw out of /api/provider-quotas. Security: the catch discards the thrown value without logging it; a synthetic secret-bearing error URL reaches neither the response nor the console.
Required checks, all successful on this head: gates, test changed, Catalog async contracts, enforce-target, hygiene, label, CodeRabbit (runs: PR gates 44794787152, PR gates 44794434435, Catalog async contracts 44794324724, ocx-ci-v1 lane=all sha=87b0a118d3667b1198d7e0691754465d416e4c96 44794324857, PR gates 44794321080).
Union check against current dev (git merge-tree --write-tree origin/dev d7fbf4cb45): clean. No touched file exceeds its file-size cap in the merged tree.
Fork CI approval: the diff changes no .github/**, workflow-executed scripts or install hooks. Approval-gated workflows run on pull_request with read-only permissions and no secrets.
Verification
Focused: provider-quota-probe-isolation, provider-quota, DeepSeek quota and the layout/size guards: 220 pass, 0 fail. Typecheck and structure:check pass. This lane finished the draft (dev merge, readiness checklist).
Full local suite: NOT RUN (resource exception; parallel lane worktrees on one host). CI test changed covers import-connected tests, and the batched dev dispatch covers the full and cross-platform suites.
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
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.
Summary
eader(...) for key-based vendor probes such as OpenRouter and DeepSeek) returned their promises without ^Gwait. When any of those probes threw a network error (e.g. ECONNRESET or ENOTFOUND), the rejected promise bypassed the catch block and rejected the Promise.all in etchProviderQuotaReports(), failing the entire GET /api/provider-quotas response.
eturn statements inside maybeFetchProviderQuota() so per-provider probe rejections are caught and normalized to
ull (preserving bounded last-good cached rows on transient failures and returning healthy providers' reports).
Fixes #8939
Verification
bun test tests/providers/provider-quota-probe-isolation.test.ts tests/providers/deepseek-quota-currency.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts— 40 pass, 0 failbun test tests/providers/provider-quota.test.ts— 171 pass, 0 failbun run typecheck— no type errors in 2,645 filesbun run structure:check— passedChecklist
Summary by CodeRabbit
Maintainer completion (lidge-jun)
I finished this draft for the fb-contrib-queue lane.
d7fbf4cb45merges currentdevinto the branch with a merge commit; there is no force push and no source change beyond the merge. Validation ond7fbf4cb45:provider-quota-probe-isolation,provider-quotaand the layout/size guards: 214 pass, 0 fail. Fail-before (independent terra review): with the merge-basesrc/providers/quota.ts, the OpenRouterECONNRESETand DeepSeekENOTFOUNDcases throw out of/api/provider-quotas. Security: the catch discards the thrown value without logging it; a synthetic error URL containing a key does not reach the response or the console. Full local suite: NOT RUN (resource exception); CI covers it.Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.