Skip to content

Node.js structuredClone objects do not preserve prototypes #54603

@avivkeller

Description

@avivkeller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.v22.xIssues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.web streamsweb-standardsIssues and PRs related to Web APIs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions