Repository navigation
fix(peer): keep FormData boundary case in encoded content-type - #186
Merged
Merged
Conversation
Blob.type is ASCII-lowercased, so using it as the content-type broke mixed-case multipart boundaries (e.g. Chrome's ----WebKitFormBoundary...) and the receiving side failed to parse the form data. Use the Response content-type header instead, read before consuming the body since Bun drops it afterwards when the FormData contains a File (same as the node adapter). Fixes #182 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VVaw7Qw8xM3RXrXjKh1gBc
Contributor
|
This run was cancelled before it finished. |
@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! |
Contributor
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
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.

Fixes #182
Problem
encodeAtomicStandardBodyset thecontent-typeof aFormDatabody fromblob.type.Blob.typeis ASCII-lowercased, boundary included, while the serialized body keeps the original boundary. Chrome generates mixed-case boundaries (----WebKitFormBoundary…), so the receiving peer could not find the delimiter andformData()failed (TypeError: Failed to fetch). Firefox and Node use lowercase boundaries, which hid the bug.Fix
content-typefrom theResponseheaders, which keep the original case, and read it beforeblob(): Bun drops the header once a body containing aFilehas been consumed. This matches the node adapter.response.headers.get('content-type')!.Tests
packages/peer/src/body.test.tsstubsResponseto emit a Chrome-style mixed-case boundary, then checks the encoded header and a full encode → decode round trip. It fails without the fix.buffered body formdatae2e test, which fails when the header is read afterblob().pnpm checkandpnpm testpass.Generated by Claude Code