Skip to content

fix(node): require maxBodySize in TmpFileUploadHandlerPlugin - #2543

Merged
dinwwwh merged 1 commit into
mainfrom
claude/tmp-upload-required-limits-af02c5
Nov 23, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/tmp-upload-required-limits-af02c5

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Nov 23, 2026

Copy link
Copy Markdown
Member

What

TmpFileUploadHandlerPlugin now requires maxBodySize, with memory, file and stream all required inside it. The constructor's options argument is therefore required too. The resolver-function form is unchanged.

Why

The plugin spools multipart and file bodies to os.tmpdir() before input validation. With no options it defaulted every limit to Infinity, so a single request could fill the disk. Its JSDoc and docs already said all three kinds are required "so none is left unbounded by accident", and RequestLimitHandlerPlugin, which this plugin subsumes, already requires its maxBodySize. Making it required after 2.0 would be a breaking change.

Breaking

new TmpFileUploadHandlerPlugin() and options without maxBodySize no longer compile. To keep the old behaviour, pass Number.POSITIVE_INFINITY for each kind.

Changes

  • packages/node: required option, unlimited default removed, new *.test-d.ts asserting the type errors, tests updated to pass explicit limits.
  • Docs: the first example in plugins/tmp-file-upload.mdx now shows limits, and the wording says the option is required. One sentence in the uploads blog post is corrected to match.

Not included

Temp directories named orpc-upload-* orphaned by a crash are still not swept. A sweep needs an age threshold and has to be safe when several processes share one tmpDir, so it is left for a separate decision.

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2543

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2543

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@2543

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2543

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@2543

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2543

@orpc/effect

npm i https://pkg.pr.new/@orpc/effect@2543

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@2543

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@2543

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2543

@orpc/experimental-lock

npm i https://pkg.pr.new/@orpc/experimental-lock@2543

@orpc/mcp

npm i https://pkg.pr.new/@orpc/mcp@2543

@orpc/msw

npm i https://pkg.pr.new/@orpc/msw@2543

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2543

@orpc/next

npm i https://pkg.pr.new/@orpc/next@2543

@orpc/node

npm i https://pkg.pr.new/@orpc/node@2543

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2543

@orpc/experimental-openapi-inference

npm i https://pkg.pr.new/@orpc/experimental-openapi-inference@2543

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@2543

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@2543

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@2543

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@2543

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@2543

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2543

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2543

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@2543

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2543

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2543

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2543

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2543

commit: b8c055f

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Breaking Changes
    • The temporary-file upload plugin now requires maxBodySize configuration, with limits specified for memory, files, and streams. Set a limit to Number.POSITIVE_INFINITY to leave that category unlimited.
  • Documentation
    • Updated setup and upload examples to include all three limits. Clarified that requests exceeding a configured limit are rejected with PAYLOAD_TOO_LARGE.

The upload handler plugin now requires explicit limits for memory, files, and streams. Tests and documentation now provide or describe those limits.

Changes: Upload body-size limits

Layer / File(s) Summary
Require explicit body-size limits
packages/node/src/tmp-file-upload-handler-plugin.ts, packages/node/src/tmp-file-upload-handler-plugin.test-d.ts, apps/content/docs/plugins/tmp-file-upload.mdx, apps/content/blog/uploads-bigger-than-your-ram.mdx
maxBodySize is required, and the plugin no longer defaults each limit to Number.POSITIVE_INFINITY. Type tests and documentation cover the required memory, file, and stream limits.
Set limits in plugin tests
packages/node/src/tmp-file-upload-handler-plugin.test.ts, packages/node/tests/uploads-large-files.test.ts
Tests that previously omitted plugin options now pass explicit unlimited limits for memory, files, and streams.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to b8c05

This change requires callers to set explicit upload size limits, so existing code that relied on the unlimited defaults will need updating. The change is intentional, documented, and covered by updated tests, and no remaining merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: TmpFileUploadHandlerPlugin now requires maxBodySize. The raw summary confirms the option becomes required, the unlimited default is removed, and the constructor option…
Description check Passed The description states that TmpFileUploadHandlerPlugin now requires maxBodySize with memory, file, and stream inside it. It explains the disk-exhaustion motivation, the breaking change, and the migrat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: TmpFileUploadHandlerPlugin now requires maxBodySize. The raw summary confirms the option becomes required, the unlimited default is removed, and the constructor options argument is required. The title uses the fix(node) prefix and stays within one short sentence.

Full details: Description check

Explanation

The description states that TmpFileUploadHandlerPlugin now requires maxBodySize with memory, file, and stream inside it. It explains the disk-exhaustion motivation, the breaking change, and the migration path using Number.POSITIVE_INFINITY. It also lists the changed files, including the docs, tests, and type-test file. This matches the changeset.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b5be5de3-710a-44e9-81bb-9bbe0af9f1fd
Commits

Reviewing files that changed from the base of the PR and between ab8311a and b8c055f.

Files selected for processing: 6

  • apps/content/blog/uploads-bigger-than-your-ram.mdx
  • apps/content/docs/plugins/tmp-file-upload.mdx
  • packages/node/src/tmp-file-upload-handler-plugin.test-d.ts
  • packages/node/src/tmp-file-upload-handler-plugin.test.ts
  • packages/node/src/tmp-file-upload-handler-plugin.ts
  • packages/node/tests/uploads-large-files.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound — the plugin is still pre-2.0 beta and the unbounded default was the disk-fill vector, so requiring maxBodySize turns "unlimited" into a deliberate Number.POSITIVE_INFINITY choice that matches what the JSDoc and docs already claimed.

Reviewed changes — full diff (6 files, 1 commit), plus repo-wide call-site and docs checks:

  • Required option, no fallback — maxBodySize loses | undefined and the constructor loses its = {} default; this.maxBodySize = options.maxBodySize replaces the POSITIVE_INFINITY default. The resolver-function form is untouched.
  • Type-level regression test — the new tmp-file-upload-handler-plugin.test-d.ts asserts the no-arg, empty-object, and missing-kind cases all fail to compile, and that fixed and async limits compile. I confirmed the file is actually typechecked: injecting an unused @ts-expect-error makes pnpm check fail with TS2578, so the assertions are not a silent no-op.
  • Tests — every construction site uses explicit limits now (UNLIMITED in the unit suite, the pre-existing UNLIMITED in the e2e suite), preserving prior coverage. Repo-wide grep found no missed call sites in other packages, playgrounds, or docs.
  • Docs — the setup example, the "Limiting Body Sizes" wording, the "subsumes the request limit plugin" sentence, and the blog sentence are all consistent with the new contract; no remaining claim that the option is optional.

Verified locally: pnpm check clean (1155 files), the two @orpc/node suites pass (61 tests), pnpm docs:validate clean, and oxfmt --check clean on all six files.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

@codspeed

codspeed Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 40 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing claude/tmp-upload-required-limits-af02c5 (b8c055f) with main (ab8311a)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
orpc b8c055f Commit Preview URL

Branch Preview URL
Nov 23 2026, 10:04 AM

@dinwwwh
dinwwwh merged commit bc815e0 into main Nov 23, 2026
13 checks passed
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.

1 participant