Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.32.0 : TypeError: Cannot assign to read only property 'structuredClone' of object '[object global]' #1281

Open
jean-humann opened this issue Aug 9, 2023 · 6 comments

Comments

@jean-humann
Copy link

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 ?

@joealden
Copy link

joealden commented Aug 9, 2023

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?

@jean-humann
Copy link
Author

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

@zloirock
Copy link
Owner

zloirock commented Aug 9, 2023

core-js is tested in those Node versions. They have an acceptable structuredClone descriptor:

image

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.

@joealden
Copy link

joealden commented Aug 9, 2023

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.

NeoPlays added a commit to stereum-dev/ethereum-node that referenced this issue Aug 11, 2023
this zloirock/core-js#1281
is the issue we're facing. I'll set the node version for these integration tests to 18 for now
@sibelius
Copy link

sibelius commented Sep 5, 2023

is this a bug on core-js or jest ?

@zloirock
Copy link
Owner

zloirock commented Sep 6, 2023

@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.

doug-wade added a commit to doug-wade/itscalledsoccer-js that referenced this issue Oct 5, 2023
delanni added a commit to elastic/kibana that referenced this issue Jan 8, 2024
…one' (#174444)

## Summary
@CoenWarmer found that `--watch` on jest tests will cause this sort of
error:
```
    TypeError: Cannot assign to read only property 'structuredClone' of object '[object global]'
```

There's some workaround suggested on this thread (although not
necessarily related): zloirock/core-js#1281

In the workaround, we set `structuredClone` to `{}`, this would allow
the currently offending 3rd party to overwrite it where it's currently
getting an error.
plasmicops pushed a commit to plasmicapp/plasmic that referenced this issue Jan 9, 2024
The workaround to fix `structuredClone` type error  in jest.config.js
was found in zloirock/core-js#1281 and came
from elastic/kibana@a5dbf26

Change-Id: I18163a5b7fd0a25cc3d65b69d25499c32e8614ca
GitOrigin-RevId: 19b1612b23f2dfb75f0fb6b8c3ab9a7323609bd1
delanni added a commit to delanni/kibana that referenced this issue Jan 11, 2024
…one' (elastic#174444)

## Summary
@CoenWarmer found that `--watch` on jest tests will cause this sort of
error:
```
    TypeError: Cannot assign to read only property 'structuredClone' of object '[object global]'
```

There's some workaround suggested on this thread (although not
necessarily related): zloirock/core-js#1281

In the workaround, we set `structuredClone` to `{}`, this would allow
the currently offending 3rd party to overwrite it where it's currently
getting an error.
Nimbus1102 added a commit to Nimbus1102/ethereum-node that referenced this issue Aug 8, 2024
this zloirock/core-js#1281
is the issue we're facing. I'll set the node version for these integration tests to 18 for now
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

No branches or pull requests

5 participants
@sibelius @zloirock @joealden @jean-humann and others