fix(node): don't crash on Bun when encoding an empty-named File - #98
Conversation
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.
@standard-server/aws-lambda
@standard-server/core
@standard-server/fastify
@standard-server/fetch
@standard-server/node
@standard-server/peer
@standard-server/shared
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — the node send adapter's Blob/File encoding path and its new regression test.
toNodeHttpBodyempty-name fallback —body.name ?? ''replaces a barebody.name, so an empty-namedFileno longer passesundefinedintogenerateContentDispositionand throws on Bun.- Regression test — constructs a
Filewhosenameis forced toundefinedand assertsgenerateContentDispositionreceives''.
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.
DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

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-namedFileanameofundefined, sogenerateContentDispositionthrew before any headers were sent. The fetch and peer adapters already fall back to'', and now the node adapter does too.Fixes
Testing
undefinedfile name. It fails without the fix and passes with it. The node body suite passes (34/34), and lint and type-check are clean.tests/bunonly covers the fetch and peer adapters, which is why this wasn't caught earlier.