Skip to content

fix(jsdom): unwrap Blob via jsdom's implForWrapper (fix #11336) - #11370

Closed
nanami-0713 wants to merge 1 commit into
vitest-dev:mainfrom
nanami-0713:fix/jsdom-blob-private-impl
Closed

nanami-0713 wants to merge 1 commit into
vitest-dev:mainfrom
nanami-0713:fix/jsdom-blob-private-impl

Conversation

@nanami-0713

Copy link
Copy Markdown

What happens

Under environment: 'jsdom' with jsdom ≥ 30.1.0, every path that goes through makeCompatBlob throws:

TypeError: Cannot read properties of undefined (reading '_bytes')

This breaks URL.createObjectURL(new Blob(...)) and Request/FormData bodies holding a jsdom Blob (#11336). jsdom 30.0.1 still works; #11295 (shipped in 5.0.2) doesn't cover it because the failure happens one step earlier than the _buffer → _bytes rename it fixed.

Root cause

jsdom 30.1.0 moved the implementation object from the hidden Symbol(impl) own property into a private class field (#impl in wrapper). createCompatUtils finds the impl by scanning the own symbols of a Blob instance, so implSymbol is now undefined and blob[implSymbol] returns undefined:

// own symbols on `new window.Blob(['x'])`
// jsdom 30.0.1 -> [ Symbol(impl) ]
// jsdom 30.1.0 -> []

Fix

Use jsdom's own implForWrapper, which can unwrap both layouts. It is not exported from the package entry, but jsdom has no exports map, so the module subpath can be required directly. The new subpath (lib/generated/idl/utils.js, present in 29 and 30.1) is tried first, the old one (lib/jsdom/living/generated/utils.js, older releases) second, and the existing symbol scan stays as a last-resort fallback.

Testing

  • Repo unit tests (test/unit/test/environments/jsdom.spec.ts) still pass on the repo's jsdom 29: 25/25, including the strengthened URL.createObjectUrl works properly assertions added here. Note the repo suite runs jsdom 29, where the old symbol path still works, so the 30.1-specific break cannot go red there — that's why the scratch-project run below is part of the verification.
  • Scratch project pinning jsdom@30.1.0 and vitest from pnpm pack of this branch, running the two tests from the issue:
    • build of main (unpatched): 2 failed with exactly Cannot read properties of undefined (reading '_bytes')
    • build of this branch: 2 passed
  • Verified implForWrapper resolution on both sides: jsdom 29.1.1 and 30.1.0 both export it from lib/generated/idl/utils.js (the old subpath is gone by 29 already), and on 30.1.0 implForWrapper(blob)._bytes yields the blob's bytes while the blob has zero own symbols.
  • eslint passes on both changed files.

AI disclosure

The fix and this description were drafted with AI assistance (ZCode/GLM); the reproduction and verification chain above was executed by me on this machine against real jsdom 29/30.1 installs and a real build of this branch.

Fixes #11336

…ort jsdom 30.1

jsdom 30.1 moved the implementation object from the hidden Symbol(impl)
own property into a private class field, so the symbol scan in
createCompatUtils finds nothing and every makeCompatBlob caller
(URL.createObjectURL, Request/FormData bodies) throws
"Cannot read properties of undefined (reading '_bytes')".

Resolve the implementation with jsdom's own implForWrapper instead
(jsdom has no exports map, the subpath can be required directly),
keeping the symbol scan as a fallback for older layouts.
@github-actions github-actions Bot added the bot Confirmed bot account. Added automatically by agentscan to community flagged accounts label Sep 27, 2026
@github-actions

Copy link
Copy Markdown

Your account has been automatically flagged as likely to be created by a bot, LLM, or agent,
and will be automatically closed. If you believe this is a mistake, please reply to this comment and we will review it.

These measures help us reduce maintenance burden and keep the team's work efficient. See our AI contributions policy for more context.

@github-actions github-actions Bot closed this Sep 27, 2026
@netlify

netlify Bot commented Sep 27, 2026

Copy link
Copy Markdown

✅ Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 0fa55c4
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6ab91b4c84d68c00084fff68
😎 Deploy Preview https://deploy-preview-11370--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@nanami-0713

Copy link
Copy Markdown
Author

I am the author of this PR—a real human developer—and I would like to request a manual review after seeing my account flagged as a suspected bot by agentscan. Although this account is relatively new (registered in August 2026), it is my primary development account and hosts 34 public repositories.
As required by the AI ​​policy in the CONTRIBUTING guidelines, I have already disclosed at the end of the PR description that the work involved "AI assistance and local verification by the author."
I have locally executed the full reproduction steps for the fix; maintainers are welcome to re-run any specific step they choose.
Thanks.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bot Confirmed bot account. Added automatically by agentscan to community flagged accounts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

jsdom 30.1: URL.createObjectURL and Blob request bodies throw Cannot read properties of undefined (reading '_buffer')

1 participant