-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
sync-channels panicking #2406
Comments
Hey What you're seeing is expected. I think that that is blocked by rust-lang/rust#77839 In the meantime you can consider using threads https://rustwasm.github.io/docs/wasm-bindgen/examples/raytrace.html , if they work for your use case. Cheers |
I was afraid it would be expected, but still wanted to make sure there was not a simple trick to overcome it... Thanks for the link to threads - there are some many warnings in that example that I don't want to go into this minefield. Is there another channel library that could work? |
Unfortunately none of my Rust work in the browser uses JS so I don't have any thoughts based on experience. If all you're trying to do is do nothing until JS gives you a value you could try:
Another alternative is https://rustwasm.github.io/docs/wasm-bindgen/reference/js-promises-and-rust-futures.html Really depends on what you're trying to do. Note that I haven't used either of the above approaches so YMMV |
Thanks a lot for the pointers. I ended up polling the channel using Shall I close this issue, or leave it open in the hope that this gets fixed sometimes? |
Nice! This is less of a wasm-bindgen issue and more of an issue of synchronization primitives in the wasm world at large are still a work in progress - so I'd say you can close this issue. Good luck with your work |
Describe the Bug
I'm trying to use
std::sync::mpsc
to synchronize between the js-world and the wasm-world. Unfortunately I always get the following panicks:Steps to Reproduce
I created an example code at https://github.com/ineiti/sync-channel that shows the error. It is mostly the following code:
I'm quite new to rust/wasm, so I probably copy/pasted the wrong examples together. But I tried different versions of this, and it always failed with the sync-channel failures.
Expected Behavior
The code should wait on the
r1.recv()
until thesetTimeout
sends the data through.Actual Behavior
The text was updated successfully, but these errors were encountered: