node icon indicating copy to clipboard operation
node copied to clipboard

Node.js `structuredClone` objects do not preserve prototypes

Open avivkeller opened this issue 1 year ago • 0 comments

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.

avivkeller avatar Aug 28 '24 01:08 avivkeller