Skip to content

fix(node): don't crash on Bun when encoding an empty-named File - #98

Merged
dinwwwh merged 1 commit into
mainfrom
claude/node-body-name-bun-crash-57bb2b
Sep 25, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/node-body-name-bun-crash-57bb2b

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Sep 25, 2026

Copy link
Copy Markdown
Member

Running the node adapter on Bun could crash while sending a file. It happened when a request's content-disposition: attachment; filename="" came back out as a response. Bun gives an empty-named File a name of undefined, so generateContentDisposition threw before any headers were sent. The fetch and peer adapters already fall back to '', and now the node adapter does too.

Fixes

  • Empty-named files now encode on Bun instead of throwing, so the node adapter handles them the same way as fetch and peer.

Testing

  • Added a regression test that simulates Bun's undefined file name. It fails without the fix and passes with it. The node body suite passes (34/34), and lint and type-check are clean.
  • Note: the Bun runtime suite in tests/bun only covers the fetch and peer adapters, which is why this wasn't caught earlier.

Bun returns `undefined` for an empty File name, so a request carrying
`content-disposition: attachment; filename=""` parsed into a File whose
name made generateContentDisposition throw when echoed back. The fetch and
peer adapters already fall back to ''; the node adapter now does too.
@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026

Copy link
Copy Markdown
@standard-server/aws-lambda

npm i https://pkg.pr.new/@standard-server/aws-lambda@98

@standard-server/core

npm i https://pkg.pr.new/@standard-server/core@98

@standard-server/fastify

npm i https://pkg.pr.new/@standard-server/fastify@98

@standard-server/fetch

npm i https://pkg.pr.new/@standard-server/fetch@98

@standard-server/node

npm i https://pkg.pr.new/@standard-server/node@98

@standard-server/peer

npm i https://pkg.pr.new/@standard-server/peer@98

@standard-server/shared

npm i https://pkg.pr.new/@standard-server/shared@98

commit: 1daf2d7

@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 108 skipped benchmarks1


Comparing claude/node-body-name-bun-crash-57bb2b (1daf2d7) with main (e92aea4)2

Open in CodSpeed

Footnotes

  1. 108 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. ↩

  2. No successful run was found on main (469d94b) during the generation of this report, so e92aea4 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@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.

Reviewed changes — the node send adapter's Blob/File encoding path and its new regression test.

  • toNodeHttpBody empty-name fallback — body.name ?? '' replaces a bare body.name, so an empty-named File no longer passes undefined into generateContentDisposition and throws on Bun.
  • Regression test — constructs a File whose name is forced to undefined and asserts generateContentDisposition receives ''.

The fallback matches the fetch (packages/fetch/src/body.ts:111) and peer (packages/peer/src/body.ts:126) adapters exactly, and the test is genuinely discriminating: reverting the ?? '' fails at packages/node/src/body.test.ts:562 (expected [ '' ], received undefined), while the fix passes 34/34.

Pullfrog  | View workflow run | Using DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

@dinwwwh
dinwwwh merged commit cc041e5 into main Sep 25, 2026
15 of 17 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