-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
worker.send stripping Map and replacing with {} #10965
Comments
This is because |
Example solution that should work: class SerializableMap extends Map {
toJSON() {
const obj = Object.create(null);
for (const [key, value] of this) {
obj[key] = value;
}
return obj;
}
}
let worker = cluster.fork();
let myMap = new SerializableMap();
myMap.set('s', {foo: 'bar'});
worker.send({
myMap
}); Other than that @cjihrig covered everything already, so closing. |
@TimothyGu are you okay with me reopening this? I’d like to see how far we can get with the |
@addaleax no problem at all. Just trying to cleaning up some old and inactive issues. |
@addaleax Is this still something you intend to look at? Or should this be closed? |
Yes, but it’s not something we can realistically do until V8 moves its API out of experimental status, I think (because this is about a non-experimental API of ours). |
Is this something we still want to pursue? In that case I guess it makes sense to add the |
@addaleax @TimothyGu Could you give a quick status update on this? I'm not familiar enough with V8 to know where this is at. Thank you! |
Still experimental. There's also the issue that JSON is the documented serialization protocol so there might be applications or libraries out there relying on quirks of |
Might someone supply another status update on this one for those of us who don't follow V8 and wouldn't know where to look? |
@nodejs/v8 ^^^ (tl;dr: When does |
ping @addaleax |
Add an `serialization` option that allows child process IPC to use the (typically more powerful) V8 serialization API. Fixes: nodejs#10965
Add an `serialization` option that allows child process IPC to use the (typically more powerful) V8 serialization API. Fixes: #10965 PR-URL: #30162 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Add an `serialization` option that allows child process IPC to use the (typically more powerful) V8 serialization API. Fixes: nodejs#10965 PR-URL: nodejs#30162 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Add an `serialization` option that allows child process IPC to use the (typically more powerful) V8 serialization API. Fixes: #10965 PR-URL: #30162 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
Add an `serialization` option that allows child process IPC to use the (typically more powerful) V8 serialization API. Fixes: #10965 PR-URL: #30162 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
When the worker gets the message myMap becomes {}
When sending an array or object it works as expected
The text was updated successfully, but these errors were encountered: