feat(api): raise the default per-IP rate limit to 600/min - #73
Merged
Conversation
The 60/min default was sized for one polite browser tab. Measured on
preprod: an idle SPA tab uses 3 counted requests/min and an active trader
10-15/min, but the solver console polls 4 counted routes every 4 s (60/min)
and the solver's settlement sweep plus a book page-through bursts to ~400/min,
so any co-located automated client hit 429 RATE_LIMITED on its own.
600/min covers a solver plus its console on one address with headroom; the
deploy scaffold keeps its explicit 6000. Docs now describe the real 429 body
(`{statusCode, error: RATE_LIMITED, reason}`) and the x-ratelimit-* headers
instead of a response shape the limiter never sent.
acedward
marked this pull request as ready for review
September 11, 2026 01:34
This was referenced Sep 11, 2026
Merged
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.
Why
The 60/min default was sized for one polite browser tab. Measured on preprod (2026-09-09/10): an idle SPA tab uses 3 counted requests/min and an active trader 10–15/min, but the solver console polls 4 counted routes every 4 s (60/min) and the solver's settlement sweep plus a book page-through bursts to ~400/min, so any co-located automated client hit
429 RATE_LIMITEDon its own.What
API_RATE_LIMIT_MAXdefault 60 → 600 (packages/node/env.ts);deploy/keeps its explicit 6000.{statusCode, error: "RATE_LIMITED", reason}) and thex-ratelimit-*headers instead of a shape the limiter never sent (API.md, README env table, FRONTEND-API-HANDOFF, deploy/.env.example).Not breaking: deployments that set the variable are unaffected.
Companion
The per-user part of the fix is in the effectstream runtime (Fastify
trustProxy): behind nginx every browser currently shares one bucket becauserequest.ipis the proxy. Kernelmaingets it via themidnight-1port,ledger-v9viav-next;ledger-v9takes this PR by the usualmainmerge (PR #65 comment).Tests
bun test packages/node/api-rate-limit.test.ts: 3 pass / 0 failbun run typecheck:backend: 0 diagnostics