feat(node): resolve tmp file upload body limits per request - #1881
Conversation
|
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! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
maxBodySizeresolver:TmpFileUploadHandlerPluginOptions<T>is now generic in the handler context andmaxBodySizeaccepts either the fixed object or a sync/async resolver overStandardHandlerRoutingInterceptorOptions<T>(context,request,prefix), matchingBatchHandlerPluginOptions.resolveBodyrefactor: now takes the fullinterceptorOptionsand resolves limits via a singleawait value(...)per parsed body, feeding all three limits and the multipart total from one snapshot.'none'early return: a body-less request skips the resolver and resolves via the standard parser — preserving the old catch-all behavior while avoiding needless lookups.- Tests: context-driven guest-reject / authed-admit for memory and spooled bodies, tmp cleanup on rejection, and a no-body-skips-resolver case.
- Docs: new "Per-Request Limits" section.
I verified the type shape (StandardHandlerRoutingInterceptorOptions<T> is exactly { prefix?, context, request }, so the resolver's runtime args match its signature), the closed hint union (json | form-data | url-search-params | event-stream | octet-stream | file | none — the fallthrough to parseLimitedBody(stream) is behavior-preserving, since 'none' is the only prior catch-all member and is now handled explicitly), and that the tests genuinely fail without per-context resolution.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

TmpFileUploadHandlerPlugin'smaxBodySizenow accepts a function, sync or async, alongside the fixed object it already took. The function receives the routing interceptor options (context,request,prefix), so an upload allowance can follow the request that carries it, such as a larger file limit for an authenticated user than for a guest.Behavior
maxBodySizeobject behaves exactly as before, and remains the default when the option is omitted.memory,file, and their combined total from a single consistent snapshot.Types
TmpFileUploadHandlerPluginOptionsis now generic in the handler context, matchingBatchHandlerPluginOptions. Existing call sites that pass a fixed object keep compiling untouched;new TmpFileUploadHandlerPlugin<AppContext>({ ... })typescontextinside the resolver.Testing
Three cases cover context-driven limits rejecting a guest and admitting an authenticated user for memory-parsed bodies and for spooled files, with temporary files still cleaned up on rejection, plus a case asserting the resolver is skipped when no body is parsed. 145 tests pass across
packages/node; root type check and lint are clean.