Skip to content

Backport structuredClone to Node v16 #40756

Description

@fregante

#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

Activity

  1. lpinca commented on Nov 9, 2021

    @lpinca
    Member

    #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

  2. MylesBorins commented on Nov 9, 2021

    @MylesBorins
    Contributor

    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

  3. added
    feature requestIssues requesting new Node.js features.
    and removed
    questionIssues asking questions about Node.js.
    on Nov 20, 2021
  4. dinuvld commented on Feb 8, 2022

    @dinuvld

    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.

  5. DerekNonGeneric commented on Feb 8, 2022

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

  6. richardlau commented on Feb 8, 2022

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

  7. moved this to Pending Triage in Node.js feature requestson Apr 4, 2022
  8. voxpelli commented on Apr 29, 2022

    @voxpelli

    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?

  9. aduh95 commented on Apr 29, 2022

    @aduh95
    Contributor

    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)

  10. github-actions commented on Nov 6, 2022

    @github-actions
    Contributor

    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.

  11. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Nov 6, 2022
  12. github-actions commented on Dec 7, 2022

    @github-actions
    Contributor

    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.

  13. moved this from Pending Triage to Stale in Node.js feature requestson Apr 4, 2023
  14. added a commit that references this issue on Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions