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

Node.js structuredClone objects do not preserve prototypes #54603

Closed
RedYetiDev opened this issue Aug 28, 2024 · 5 comments · Fixed by #55067
Closed

Node.js structuredClone objects do not preserve prototypes #54603

RedYetiDev opened this issue Aug 28, 2024 · 5 comments · Fixed by #55067
Labels
confirmed-bug Issues with confirmed bugs. v22.x v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch. web streams web-standards Issues and PRs related to Web APIs

Comments

@RedYetiDev
Copy link
Member

When using structuredClone with and transferring the original in Node.js, the resulting clone's prototype is not the same as the original's. However, in other environments, the prototype remains consistent.

const original = new ReadableStream();
const transfer = structuredClone(original, { transfer: [original] });
console.log(Object.getPrototypeOf(transfer) === ReadableStream.prototype);

In Node.js, the above snippet logs false, however, in other environments, it logs true.

@RedYetiDev RedYetiDev changed the title Node.js structuredClone objects do not preverse prototypes Node.js structuredClone objects do not preserve prototypes Aug 28, 2024
@RedYetiDev RedYetiDev added repro-exists web-standards Issues and PRs related to Web APIs labels Aug 28, 2024
@RedYetiDev RedYetiDev added the abortcontroller Issues and PRs related to the AbortController API label Sep 7, 2024
@RedYetiDev RedYetiDev removed the abortcontroller Issues and PRs related to the AbortController API label Sep 18, 2024
@RedYetiDev
Copy link
Member Author

CC @nodejs/web-standards

@RedYetiDev RedYetiDev added confirmed-bug Issues with confirmed bugs. and removed repro-exists labels Sep 18, 2024
@dnalborczyk
Copy link
Contributor

dnalborczyk commented Sep 18, 2024

In Node.js, the above snippet logs false, however, in other environments, it logs true.

the code snippet from above logs true in v18.20.4 and v20.17.0, and false for v22.9.0.

@RedYetiDev RedYetiDev added the v22.x v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch. label Sep 18, 2024
@RedYetiDev
Copy link
Member Author

RedYetiDev commented Sep 18, 2024

Interesting. I'll see if I can narrow down a specific commit. The issue starts with v22.0.0. @nodejs/v8 does this have something to do with V8? I can't reproduce in Chrome.

@targos
Copy link
Member

targos commented Sep 19, 2024

It's probably caused by #50107

@RedYetiDev
Copy link
Member Author

CC @H4ad

targos pushed a commit that referenced this issue Oct 4, 2024
PR-URL: #55067
Fixes: #54603
Refs: #50107
Reviewed-By: Mattias Buelens <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
louwers pushed a commit to louwers/node that referenced this issue Nov 2, 2024
tpoisseau pushed a commit to tpoisseau/node that referenced this issue Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. v22.x v22.x Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch. web streams web-standards Issues and PRs related to Web APIs
Projects
None yet
3 participants