Skip to content

fix: make HTTP rate-store policy authoritative - #1777

Merged
kang-heewon merged 1 commit into
trunkfrom
fix/1709-rate-store-policy
Aug 8, 2026
Merged

fix: make HTTP rate-store policy authoritative#1777
kang-heewon merged 1 commit into
trunkfrom
fix/1709-rate-store-policy

Conversation

@kang-heewon

Copy link
Copy Markdown
Member

Outcome

HTTP rate-limit middleware now passes its failOpen choice into each limiter check, so store outages follow the HTTP policy even when the RateLimiter constructor uses the opposite default. Fail-closed requests reject with recovery headers; fail-open requests continue with an explicit degraded result.

Runtime inspection records one rate-limit.store-unavailable failure event with the policy name and actual allowed or rejected action. The middleware factory forwards the same policy.

Fixes #1709

Verification

  • pnpm --filter @croco/ratelimit-core test — 92 passed
  • pnpm --filter @croco/transports-http test — 414 passed
  • Both affected package typecheck, lint, and build commands — passed
  • pnpm public-api:check — 115 package snapshots match
  • pnpm problem-registry:check — 581/581 codes match
  • pnpm package-manifests:check — 115 manifests normalized
  • pnpm docs:api-triggers:check — passed
  • pnpm changeset-required:check -- --base origin/trunk --head HEAD — passed
  • pnpm check — 24/25 passed, one not applicable
  • Pre-push workspace test — 234/234 tasks passed
  • Pre-push workspace typecheck — 233/233 tasks passed
  • Isolated generated docs build — 116/116 tasks and 4,526 pages passed

Review gates

  • Correctness and regression — PASS. Failing-store HTTP tests use limiter defaults opposite to middleware settings and prove deterministic rejection, degraded allowance, headers, one diagnostic across downstream errors, and factory propagation. Existing package suites pass.
  • API, security, compatibility, and release — PASS. Direct limiter behavior is unchanged unless the new optional per-check override is supplied. HTTP defaults now enforce their documented fail-closed policy. Public API snapshots, affected generated docs, README guidance, and patch changesets for both packages are synchronized; dependencies and lockfile are unchanged.
  • Maintainability and minimality — PASS. The change threads one existing boolean through the established limiter boundary, derives diagnostics from the actual result, and leaves quota algorithms and proxy identity untouched.
  • Independent adversarial review — PASS after fix. The only finding was stale generated rate-limit API documentation; the new type, method parameters, and factory option are now synchronized.

Validation gap

The full API-doc drift run identified four pre-existing unrelated generated files on the current base (Problem.md, CROCO_PROBLEM_CODE_REGISTRY.md, TrpcRouterOptions.md, and ParamResolver.md). This PR synchronizes only the three affected rate-limit API artifacts to avoid unrelated generated churn.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@kang-heewon, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 55bb9731-e8bf-43fd-bb32-7efd61e20d6e

📥 Commits

Reviewing files that changed from the base of the PR and between f5eb334 and f1e5b46.

📒 Files selected for processing (14)
  • .changeset/fair-pandas-rate-limit.md
  • packages/docs/src/content/docs/api/ratelimit-core/src/classes/RateLimiter.md
  • packages/docs/src/content/docs/api/ratelimit-core/src/type-aliases/RateLimitCheckOptions.md
  • packages/docs/src/content/docs/api/transports-http/src/type-aliases/RateLimitMiddlewareFactoryOptions.md
  • packages/ratelimit-core/README.md
  • packages/ratelimit-core/src/index.ts
  • packages/ratelimit-core/src/libs/RateLimiter.ts
  • packages/ratelimit-core/src/libs/middleware/rateLimitMiddleware.ts
  • packages/ratelimit-core/src/tests/RateLimitMiddleware.spec.ts
  • packages/ratelimit-core/src/tests/RateLimiter.spec.ts
  • packages/transports-http/README.md
  • packages/transports-http/src/libs/middleware/RateLimitMiddleware.ts
  • packages/transports-http/src/tests/RateLimitMiddleware.spec.ts
  • public-api-surface.snapshot.json

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

📊 Benchmark Results

✅ All benchmarks passed

Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 44.0μs 30.0ms 8.2μs +438.5% -
CrocoApp lambdaHandler (10 controllers) 2.1ms 50.0ms 258.4μs +701.8% -
Lambda cold-start simulation 2.0ms 80.0ms 418.1μs +385.6% -
Lambda cold-start with headers 1.6ms 80.0ms 369.7μs +327.4% -
Lambda cold-start with binary body 1.5ms 80.0ms 339.1μs +350.3% -
Lambda cold-start with query params 1.5ms 80.0ms 301.3μs +402.5% -
Lambda cold-start with authorizer context 1.5ms 80.0ms 299.8μs +410.9% -
Lambda cold-start realistic scenario 1.5ms 80.0ms 299.2μs +407.3% -
EventBusConfig.start (10 handlers) 1.7μs 10.0ms 1.4μs +16.1% -
EventPublisher.publishNow single event 2.0μs 2.0ms 1.7μs +16.7% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.1μs +0.0% -
Container.get singleton (cold) 91.8μs 5.0ms 70.3μs +30.7% -
Container.register × 50 components 3.4ms 10.0ms 3.2ms +3.9% -
Container.validate (50 components) 3.8ms 20.0ms 3.4ms +12.3% -
Container.get singleton (warm) 1.7μs 500.0μs 1.6μs +3.1% -
TelemetryRuntime.init (lambda preset) 2.3μs 200.0ms 1.1ms -99.8% -
lambdaPreset config creation 1.7μs 2.0ms 1.4μs +16.2% -

Updated: 2026-08-08T19:53:50.225Z · Commit: 454be99

@kang-heewon
kang-heewon force-pushed the fix/1709-rate-store-policy branch from c1e51bf to f1e5b46 Compare August 8, 2026 19:46
@kang-heewon
kang-heewon merged commit ab4453f into trunk Aug 8, 2026
12 checks passed
@kang-heewon
kang-heewon deleted the fix/1709-rate-store-policy branch August 8, 2026 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ratelimit-core] Make middleware failOpen govern rate-store outages

1 participant