Repository navigation
fix(jsdom): unwrap Blob via jsdom's implForWrapper (fix #11336) - #11370
nanami-0713 wants to merge 1 commit into
Conversation
…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.
|
Your account has been automatically flagged as likely to be created by a bot, LLM, or agent, These measures help us reduce maintenance burden and keep the team's work efficient. See our AI contributions policy for more context. |
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
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. |
What happens
Under
environment: 'jsdom'with jsdom ≥ 30.1.0, every path that goes throughmakeCompatBlobthrows:This breaks
URL.createObjectURL(new Blob(...))andRequest/FormDatabodies holding a jsdomBlob(#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→_bytesrename 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).createCompatUtilsfinds the impl by scanning the own symbols of aBlobinstance, soimplSymbolis nowundefinedandblob[implSymbol]returnsundefined:Fix
Use jsdom's own
implForWrapper, which can unwrap both layouts. It is not exported from the package entry, but jsdom has noexportsmap, 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
test/unit/test/environments/jsdom.spec.ts) still pass on the repo's jsdom 29: 25/25, including the strengthenedURL.createObjectUrl works properlyassertions 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.jsdom@30.1.0andvitestfrompnpm packof this branch, running the two tests from the issue:main(unpatched): 2 failed with exactlyCannot read properties of undefined (reading '_bytes')implForWrapperresolution on both sides: jsdom 29.1.1 and 30.1.0 both export it fromlib/generated/idl/utils.js(the old subpath is gone by 29 already), and on 30.1.0implForWrapper(blob)._bytesyields the blob's bytes while the blob has zero own symbols.eslintpasses 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