refactor(ratelimit): record procedure and path with each rate-limit check - #1885
Merged
Merged
Conversation
… in the handler plugin context
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
ℹ️ Minor suggestions only — the feature works and is well-covered; one stale doc comment inline.
Reviewed changes
- Record procedure & path per check (
middleware.ts): theratelimitmiddleware now pushes{ path, procedure, result }into the handler plugin context instead of a bare result. - Rename & reshape plugin context (
handler-plugin.ts):results: RateLimitResult[]becomeschecks: { procedure, path, result }[]; the header-selection andretry-afterlogic now reads.result.*with identical semantics. - Tests updated (
middleware.test.ts,handler-plugin.test.ts): assertions migrated to the new entry shape; the middleware test asserts the recordedpathandprocedureexactly, so it fails if the feature regresses.
The types are consistent (MiddlewareOptions.path: string[] / procedure: AnyProcedure), the rename has no in-repo consumers outside packages/ratelimit, and the dedupe short-circuit reflecting no limiter call is coherent. Looks good.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
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.

The ratelimit handler plugin context now records which procedure each rate-limit check ran on. Each entry in the plugin context is
{ procedure, path, result }(renamed from a bareRateLimitResult[]underresultstochecks), so response interceptors and future consumers can tell which procedure produced which limit result.Changes
ratelimitmiddleware pushes the currentprocedureandpathalongside the limiter result into the handler plugin context.ratelimit-*andretry-afterheaders.Testing
pnpm type:checkpasses across all packages.