Skip to content

fix: emit valid JS for Node Buffer in uneval - #175

Merged
Rich-Harris merged 2 commits into
sveltejs:mainfrom
Nic-Polumeyv:fix/uneval-node-buffer
Aug 20, 2026
Merged

fix: emit valid JS for Node Buffer in uneval#175
Rich-Harris merged 2 commits into
sveltejs:mainfrom
Nic-Polumeyv:fix/uneval-node-buffer

Conversation

@Nic-Polumeyv

Copy link
Copy Markdown
Contributor

uneval(Buffer.alloc(4, 65)) returns new Uint8Array([AAAA]), because the element list is built from the value's own constructor and Buffer.prototype.toString decodes the bytes instead of listing them. Same shape as #171.

Reported downstream as sveltejs/kit#16603.

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b29d444

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
devalue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris

Copy link
Copy Markdown
Member

Hmm... it kinda feels like a bug that we treat Buffer as Uint8Array, though I'm not sure how we'd identify unsupported subclasses without adding overhead to get_type which is a fairly hot path. I guess for now we should just support it to be consistent with how we already work

@Rich-Harris
Rich-Harris merged commit 686e379 into sveltejs:main Aug 20, 2026
5 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.

2 participants