-
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
Worker MessageChannel #6691
Comments
Structured cloning support is a prerequisite for MessageChannel AFAIK. Ref #3557 |
- Doesn't work because Deno doesn't support MessageChannel yet (denoland/deno#6691) - which is something Comlink wants.
This comment has been minimized.
This comment has been minimized.
@lucacasonato Is there any plan to add this API soon ? |
@surma I was just looking into it today. The main issue is that we do not support transferable for |
Oh of course, you are right. Transferables! For Comlink itself I only need |
That said I don't think there are any more blockers for that functionality. I remember that @inteon was looking into that at some point. |
I am sitting in a train with nothing better to do, so I'll give it a shot 🙃 |
Got distracted and implemented |
|
@inteon Transferring I will open a WIP PR that adds |
Thank you for explaining. |
Actually, since you'd brought up WebAssembly threading, Wasm doesn't directly use JavaScript (Shared)ArrayBuffer objects. JavaScript With the implementation of that last PR, would passing |
It should work. WASM.Memory with shared: true are really SABs internally. |
Message port transfer across workers is now implemented too. It will be in the next canary release in about 40 minutes ( |
Amazing. I’ll have a play! :D Thanks for your work on this, @lucacasonato! |
@lucacasonato I tried a simple script where I pass the port to a worker, the worker thread receives an empty object, I am using the latest version (deno 1.11.2+d54e3ea (canary, x86_64-pc-windows-msvc)) |
@mhmdmar Looking at the code, you need to transfer the message port. worker1.postMessage({port: port1}, [port1]); (This is merely me looking at your JavaScript — I haven’t gotten around to testing this in Deno myself. Just as a heads up.) |
@surma This doesn't match the syntax in the browser, but even when I try this I still get the same behaviour, any ideas how to fix this ? |
@lucacasonato Cool, I tried the workaround and it works, still even though I can get the port, I don't see the postMessage handler triggered from the parent |
You need to listen on |
@lucacasonato @surma Thank you both so much, it works :) |
Seems that
MessageChannel
in missing from Deno APIs.https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel
It should be added as it allows safe communication between
Workers
The text was updated successfully, but these errors were encountered: