You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
In the browser context, in it's main thread, blocking calls cause panic, so it's really not an option to use std::sync::Mutex, or anything that can block the main thread.
I assumed Tokio channels would be fully async and wouldn't use any blocking primitives, but it looks like that's not the case. When I checked it's code, found multiple places blocking can occur, like:
Here is one of the panics I encountered while using tokio channels in the browser:
console.js:36 RuntimeError: Atomics.wait cannot be called in this context
at openmina_node_web.wasm.std::sys::sync::mutex::futex::Mutex::lock_contended::h26da324537dc575a (openmina_node_web_bg.wasm:0x11cd519)
at openmina_node_web.wasm.tokio::runtime::park::wake::h73a00f0ed933a774 (openmina_node_web_bg.wasm:0x11ab2fc)
at openmina_node_web.wasm.tokio::sync::task::atomic_waker::AtomicWaker::wake::h0953ea3f1740360a (openmina_node_web_bg.wasm:0x1219144)
at openmina_node_web.wasm.tokio::sync::mpsc::chan::Tx<T,S>::send::h0b8b79b860905134 (openmina_node_web_bg.wasm:0x109fcb4)
I'm not sure if fixing this is in the scope of this project, but we probably should add to the docs case when those certain calls might panic right?
The text was updated successfully, but these errors were encountered:
This really applies to anything in tokio::sync. Using these utilities is completely normal and they only block for a short amount of time. It's certainly not something we're going to fix.
Version
v1.37.0
Target
wasm32-unknown-unknown
Description
In the browser context, in it's main thread, blocking calls cause panic, so it's really not an option to use
std::sync::Mutex
, or anything that can block the main thread.I assumed Tokio channels would be fully async and wouldn't use any blocking primitives, but it looks like that's not the case. When I checked it's code, found multiple places blocking can occur, like:
tokio/tokio/src/sync/notify.rs
Line 213 in 8182ecf
or
tokio/tokio/src/sync/mpsc/chan.rs
Line 57 in 8182ecf
etc..
Here is one of the panics I encountered while using tokio channels in the browser:
I'm not sure if fixing this is in the scope of this project, but we probably should add to the docs case when those certain calls might panic right?
The text was updated successfully, but these errors were encountered: