-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Implement globalThis.structuredClone
#39713
Comments
YES PLEASE! |
Would love to give this a shot! I have some time this week I can get an initial PR up 🚀 |
Doing some pre investigation for this feature, I found this existing Lines 456 to 469 in 33f9b7f
Should I look to modify this? It seems to only be used in node/lib/internal/perf/usertiming.js Line 73 in 33f9b7f
Additionally, two implementation questions for StructuredSerializeWithTransfer function:
|
/cc @addaleax ... she could likely provide a lot more detail and context on these bits than anyone else. |
@Ethan-Arrowood Yeah, so … for a bit of context, the serialization/deserialization API in the Because the two APIs are used a bit differently, they have diverged a bit; in particular, Specifically, the I think a drop-in {
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;
}:
} I think that would actually do well enough in terms of performance and correctness to be added as an initial implementation. It’s obviously not ideal to create two internal |
Also, as for the questions above:
Generally speaking, that’s done through the
I think the straightforward answer here is Also, feel free to reach out in some other way if you’d want to have a synchronous conversation about this in some way 🙂 |
Thank you @addaleax ! I'll give your solution a shot for now, and then go from there. There appears to be some WPT tests for the new spec; hopefully, those will let us know if things are working or not 😁 |
Found something about |
Will this be back ported to v16? #40756 |
See whatwg/html#3414
The text was updated successfully, but these errors were encountered: