Skip to content

fix(structured-clone): preserve Blob.type across structuredClone#319

Open
watilde wants to merge 1 commit into
bytecodealliance:mainfrom
watilde:fix/structured-clone-blob-type
Open

fix(structured-clone): preserve Blob.type across structuredClone#319
watilde wants to merge 1 commit into
bytecodealliance:mainfrom
watilde:fix/structured-clone-blob-type

Conversation

@watilde

@watilde watilde commented Jun 27, 2026

Copy link
Copy Markdown

structuredClone(blob) serialized only the byte data and reconstructed the Blob with an empty type, so structuredClone(new Blob(['x'], {type: 'text/plain'})).type returned "" instead of "text/plain". A Blob's type is part of its serialized state per the File API.

Append the type as a length-prefixed UTF-8 string after the byte data on write, and read it back on read. Add an integration test covering a typed Blob, an empty type, and content/type round-tripping.

structuredClone(blob) serialized only the byte data and reconstructed
the Blob with an empty type, so structuredClone(new Blob(['x'],
{type: 'text/plain'})).type returned "" instead of "text/plain". A
Blob's type is part of its serialized state per the File API.

Append the type as a length-prefixed UTF-8 string after the byte data
on write, and read it back on read. Add an integration test covering a
typed Blob, an empty type, and content/type round-tripping.

Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
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