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

Backport structuredClone to Node v16 #40756

Closed
fregante opened this issue Nov 8, 2021 · 9 comments
Closed

Backport structuredClone to Node v16 #40756

fregante opened this issue Nov 8, 2021 · 9 comments
Labels
feature request Issues that request new features to be added to Node.js. stale

Comments

@fregante
Copy link

fregante commented Nov 8, 2021

#39713 added structuredClone and it landed in v17

Is it possible to back port it to v16? It'd be great to see it in an LTS sooner rather than later

@lpinca
Copy link
Member

lpinca commented Nov 9, 2021

#39759 was marked semver-major so no, it will not be backported unless an exception is made for this. I can't remember if there is a precedent for something like this.

cc: @aduh95 @nodejs/releasers

@MylesBorins
Copy link
Contributor

MylesBorins commented Nov 9, 2021

If the Semver-Major bit is to add a new global we could potentially backport as a requireable / importable module

edit: confirmed major was due to global

@DerekNonGeneric DerekNonGeneric added the question Issues that look for answers. label Nov 18, 2021
@targos targos added feature request Issues that request new features to be added to Node.js. v16.x and removed question Issues that look for answers. labels Nov 20, 2021
@dinuvld
Copy link

dinuvld commented Feb 8, 2022

Is there any update on when or if the feature would be backported?

Not waiting 2 years for another LTS release to get this would be amazing as it's such a useful addition. Currently adding lodash for the cloneDeep() functionality is a very bloated work-around.

@DerekNonGeneric
Copy link
Contributor

Yeah, it would be nice to have, but we are still discovering problems with it almost weekly and still need to ensure that it is spec-compliant or at least matches expected behavior and having nothing yet specified in the ECMAScript specification for it means that we have to piece together behavior specified elsewhere, so really it should only be used in experimental (non-production) settings probably only for academic purposes at the moment. The current implementation will very likely change and I wouldn't consider the current behavior safe to use in some cases, so I'm surprised it even shipped so soon, but that's just my opinion (and not a very developed one at that, so I digress).

@richardlau
Copy link
Member

Not waiting 2 years for another LTS release to get this would be amazing as it's such a useful addition.

We release new LTS lines every year. The next new LTS release (Node.js 18) is planned to become LTS in October this year.

@voxpelli
Copy link

What’s the best way to achieve identical functionality on Node 16?

Would you accept a PR for the suggestion from @MylesBorins of making it a requireable function?

Or would it be possible to extract this implementation and make it a third party polyfill on npm?

@aduh95
Copy link
Contributor

aduh95 commented Apr 29, 2022

What’s the best way to achieve identical functionality on Node 16? […] Or would it be possible to extract this implementation and make it a third party polyfill on npm?

I think making it an npm package is the easiest way to get it for Node.js 16.x. The original suggestion from Anna should Just Works™:

I think a drop-in structuredClone for Node.js could be:

{
  const { MessageChannel, receiveMessageOnPort } = require('worker_threads');
  const channel = new MessageChannel();
  channel.unref();
  globalThis.structuredClone = function structuredClone(value, transfer) {
    channel.port1.postMessage(value, transfer);
    return receiveMessageOnPort(channel.port2).message;
  }:
}

Source: #39713 (comment)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 6, 2022

There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 7, 2022

There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.

For more information on how the project manages feature requests, please consult the feature request management document.

@github-actions github-actions bot closed this as completed Dec 7, 2022
p5quared added a commit to p5quared/amplify-category-api that referenced this issue Aug 22, 2024
Update CONTRIBUTING.md to specify Node version v18.x. Jest's use of
structuredClone necessitates that the version be >=v17.x:
nodejs/node#40756
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js. stale
Projects
None yet
Development

No branches or pull requests

9 participants