Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces error classification rules and defense-in-depth patterns to correctly identify Cloudflare Workers AI free tier neuron allocation exhaustion (429 errors) as a connection-scoped quota exhaustion rather than a transient rate limit. It also includes corresponding unit tests. The reviewer suggested replacing the top-level dynamic await import statements in the test file with standard static imports for cleaner and more idiomatic TypeScript code.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const { getProviderErrorRuleMatch } = await import( | ||
| "../../open-sse/config/providerErrorRules.ts" | ||
| ); | ||
| const { classify429 } = await import("../../src/shared/utils/classify429.ts"); |
There was a problem hiding this comment.
Using top-level dynamic await import is unnecessary here and can be replaced with standard static import statements. Static imports are statically analyzable, cleaner, and more idiomatic in TypeScript.
import { getProviderErrorRuleMatch } from "../../open-sse/config/providerErrorRules.ts";
import { classify429 } from "../../src/shared/utils/classify429.ts";|
Thank you for tracking down and fixing this — the root cause diagnosis (daily free allocation body falling through QUOTA_PATTERNS) and the fix itself are correct and match what we're merging. Two other contributors (rafaumeu #6983, maxmad64bis #6981) submitted essentially the same fix around the same time; we're merging #6983 because its test suite is broader (11 assertions covering both the provider-rule and classify429 layers, plus edge cases like case-insensitivity and the JSON vs plain-string body shapes). Closing this one as superseded, with full credit for independently catching and fixing #6980 — appreciate you filing it. |
Summary
Cloudflare Workers AI free-tier exhaustion (429, body: "you have used up your daily free allocation of 10,000 neurons", workers-ai error 4006) was misclassified as a transient
rate_limit, so the connection was only locked for ~5s and the combo kept retrying every model against a budget that only resets at UTC midnight.This PR:
cloudflare-aiprovider rule inopen-sse/config/providerErrorRules.tsscopedconnection(per-account budget, same reasoning as the existingopencoderules) that returnsquota_exhaustedon a 429 whose body mentions "daily free allocation"./daily free allocation/itoQUOTA_PATTERNSinsrc/shared/utils/classify429.tsas defense-in-depth for theclassify429FromErrorpath.Test plan
tests/unit/cloudflare-ai-neuron-quota-6980.test.ts(node:test) asserts: the rule matches and yieldsquota_exhausted/connection, a generic rate-limit 429 does not match, andclassify429classifies the Cloudflare body asquota_exhausted.Closes #6980