Repository navigation
fix(core): address the #656 rate-limit review follow-ups - #740
Conversation
index.js re-exports RateLimitError at runtime, but types/core/index.d.ts did not declare it, so a strict TypeScript import gave TS2305. Re-export the declaration from @friggframework/errors and type-check a strict consumer in a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
inProcessBudgetMs read requestTimeoutMs: 0 as a 0 ms reserve, so a Requester with no request timeout could sleep until the invocation deadline and leave no time for the next request. 0, null or a missing value means the request has no time limit, so keep the largest reserve: half the time left. With no deadline there is nothing to keep. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parseResetValue read a millisecond delta such as X-RateLimit-Reset: 60000 as 60000 s. The size of a delta cannot show its unit: 60000 s (16.7 h) is also a real daily reset, and HubSpot, Pipedrive and Salesforce (api-module-library#102) send no millisecond delta. So a module that gets one declares static rateLimit.resetDeltaUnit = 'ms'. Epoch seconds and epoch milliseconds keep their size rules, and an unknown unit throws a TypeError, like an unknown parser. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The express boundary and the user-facing createHandler catch answered
a RateLimitError with a generic 500. Both now map any error with
isRateLimited to 429, Retry-After in seconds from retryAt (none when
retryAt is unknown) and { error: 'Too Many Requests', retryAt }, and
log one WARN record with the error. The mapping lives in the HTTP
adapter (core/rate-limited-response.js), not in the error. A
server-to-server handler still rethrows, so the queue worker can defer.
429, not 503: the default scope counts the limit against the caller's
own entity, and a 503 would fire 5xx alarms for an expected state.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A classify that names a 404 (or another response that is not a limit) as a limit with a time makes the Requester retry it up to 10 times and then throw RateLimitError. Say so in the Rate Limits reference, and pin the behaviour with a test so the warning stays true. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.
Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
Add resetDeltaUnit for a reset delta in milliseconds, the 429 answer of an HTTP route, scopeKey on the rate-limited token error, and the queue actions that the functions get on an external queue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…it-followups Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the requestTimeoutMs: 0 note from this branch and the 0 s queue-worker budget from #657. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
👷 Deploy Preview for friggframework-org processing.
|
|
|
🚀 PR was released in |



Stacked on #656. Fixes the 5 non-blocking notes from the #656 review (
seanspeaks, review 6003031198). One commit per note, each test-first.Changes
RateLimitErrortype (acb78b8b):types/core/index.d.tsre-exports it from@friggframework/errors. Newtypes/core/index.test.jscompiles a strict TS consumer of@friggframework/core; it gave TS2305 before the fix.requestTimeoutMs: 0reserve (48c92254): 0,nullor missing now means "no request timeout", soinProcessBudgetMskeeps the largest reserve, half the time left. With no deadline it keeps none. Fits ADR-049 §2 ("the request timeout, or half the time left when that is smaller").e27965b3): opt-instatic rateLimit.resetDeltaUnit = 'ms'. No size rule works:60000s (16.7 h) is also a real daily reset. HubSpot, Pipedrive and Salesforce in api-module-library#102 send no ms delta (Pipedrivex-ratelimit-resetis seconds; HubSpot'sX-HubSpot-RateLimit-Interval-Millisecondsis an interval no parser reads). Epoch s/ms rules stay as they are. An unknown unit throws aTypeError, like an unknown parser. Types updated.4b0843c3): the express boundary (handlers/app-handler-helpers.js) and the user-facingcreateHandlercatch map any error withisRateLimitedto 429,Retry-Afterin seconds fromretryAt(none when unknown) and{ error: 'Too Many Requests', retryAt }. One WARN record per request (frigg.http.request_rate_limited/frigg.handler.rate_limited) with the error, so the serializer addsretryAtandreason. The mapping lives in the HTTP adapter (core/rate-limited-response.js), not on the error. Server-to-server handlers still rethrow, so the queue worker can defer (feat(core): defer rate-limited queue messages through a RATE_LIMITED event #657).classifywarning (0c48fec5): Rate Limits reference warns that aclassifythat names a non-limit (a 404) as a limit makes up to 10 hinted retries, then throwsRateLimitError. A requester test pins that (mutatingMAX_HINTED_RETRIESbreaks it).Decisions to check
Retry-After, and a 503 fires 5xx alarms for an expected state. Easy to flip in one file if you prefer 503.Tests
cd packages/core && npx jest -i: 212/212 suites, 3042/3042 tests pass.*.mdandtypes/tsconfig.json, which this PR does not touch.Caveats
FetchError,HaltErrorand the other errors are also not declared on@friggframework/coretypes (only on@friggframework/errors). Out of scope here; separate follow-up.🤖 Generated with Claude Code