core-js
core-js copied to clipboard
3.32.0 : TypeError: Cannot assign to read only property 'structuredClone' of object '[object global]'
Hello core-js
community ✋,
I'm using core-js
in my jest test here
The test were working fine till dependabot open this PR to update version to 3.32.0
I have a new error in the jest test with 3.32:
TypeError: Cannot assign to read only property 'structuredClone' of object '[object global]'
at Object.<anonymous>.module.exports (node_modules/core-js/internals/define-built-in.js:13:24)
at Object.<anonymous>.module.exports (node_modules/core-js/internals/export.js:53:5)
at Object.<anonymous> (node_modules/core-js/modules/web.structured-clone.js:6[12](https://github.com/jean-humann/docs-to-pdf/actions/runs/5808871705/job/15746546250?pr=157#step:5:13):1)
at Object.<anonymous> (node_modules/core-js/full/index.js:450:1)
at Object.<anonymous> (node_modules/core-js/index.js:2:18)
Cf: https://github.com/jean-humann/docs-to-pdf/actions/runs/5808871705/job/15746546250?pr=157
Could you have a look please ?
FYI, I believe this is node version specific - v18 works fine, but v19 + v20 don't. I presume they made structuredClone
unwritable in v19 - @zloirock are there other polyfills that exist already that work around this problem? Did something change in the latest core-js release that could have impacted this?
FYI, I believe this is node version specific - v18 works fine, but v19 + v20 don't. I presume they made
structuredClone
writable in v19 - @zloirock are there other polyfills that exist already that work around this problem? Did something change in the latest core-js release that could have impacted this?
You seem right, I deepdive in the gh actions history and I found this run where v18 works for the PR but not v19 and v20 : https://github.com/jean-humann/docs-to-pdf/actions/runs/5693855907/job/15510037805
core-js
is tested in those Node versions. They have an acceptable structuredClone
descriptor:
It looks like a conflict with something else that rewrites and breaks structuredClone
.
If it's a problem reproducible in the mentioned PR, I'll take a look at this little later.
If it helps, I believe it's specific to jest-environment-node
- they are setting structuredClone
here for use in node tests. With that being said, I'm still not sure why it's node version specific - it might help if I knew where jest environment classes are actually instantiated, but I don't have a great understanding of their codebase structure.
is this a bug on core-js or jest ?
@sibelius it's not a core-js
or Node bug, something else overwrites structuredClone
and makes it non-writable - Jest it or not - I still didn't check.