-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
cannot post an Error, Map or Set between worker threads #3317
Comments
Hmmmmm... it seems that the structure clone on I will admit I don't know how we implemented cloning in Deno for workers... |
@kitsonk we currently stringify data as JSON into some buffer that is passed directly to the Rust side and pushed as a message through a channel, where the receiving end polls and parses the JSON as This is indeed not fully complying with structured clone requirements (e.g. transferables). But for |
JSON.stringify not only lose errors, also miss maps and sets. They are both pass correctly in browsers too. |
@Fenzland I agree we will need to fix this. /cc @bartlomieju for worker stuff |
There is the value serialiser in V8 that does the structured cloning: https://v8docs.nodesource.com/node-7.10/df/d48/classv8_1_1_value_serializer.html I am sure there must be APIs too for transferring as well, I just haven't found them yet. |
Well that and: https://denolib.github.io/v8-docs/classv8_1_1ValueSerializer.html so post should serialize the message and onmessage should be called with the deserialized message I think. I am not so hot at the V8 APIs though. |
Makes sense. This issue (or more general workers) are in my backlog, but I don't know when I'll get to them. If someone wants to take a stab at it I'll be happy to provide support |
@bartlomieju Oh I almost forgot I still have that v8 docs up... it has not been updated for a while. I mostly just refer to https://cs.chromium.org/chromium/src/v8/include/v8.h , which is well updated and, since it is using Google's CodeSearch, easy to look up references and usages than on Github. |
@bartlomieju we should close in favour of #3557 as that solution would solve all of this properly. |
In Chrome, all the assert successful. But in deno (until 0.23.0), they fail. After post between threads, errors, maps and sets become empty objects.
The text was updated successfully, but these errors were encountered: