Description
Recently I'm writing a wasm program using tokio_with_wasm
that runs in a standalone WebWorker (meaning that I called init functions from wasm-bindgen
in the worker). This program runs entirely in the worker, it only communicates with the main thread through onmessage
/postMessage
.
The program will just panic when calling spawn
, at
tokio-with-wasm/package/src/glue/task/mod.rs
Line 181 in b4171d7
From #27 (comment) I can see that tokio_with_wasm
doesn't allow spawning in a blocking task to avoid undefined reference to JS objects. But in my situation, wasm program running in the WebWorker is not in a blocking task, and all JS objects it uses just stay in the Worker. spawn
shouldn't panic under this situation.
The possible fix may be setting a flag to indicate whether the program is in a blocking_task, and decides to panic only when the progra was in a blocking_task.