wasm-bindgen
wasm-bindgen copied to clipboard
JsError doesn't seem to behave correctly when created inside a Worker in Firefox
Describe the Bug
When I create a instance of JsError inside the code that's running in a Worker, it doesn't behave the same as when the same code is run outside of the Worker.
For example I'm unable to web_sys::console::log* it - it behaves as if the entire call was skipped.
Similarly, when I MessagePort::send_message it, app behaves as if the call did not happen, there is not even empty message on the other side.
Finally when I try to serde_wasm_bindgen::to_value more complex structure which contains such a value, I get empty {} where I would expect the error to be.
Above described cases work as expected when the same code is run outside of the worker.
Steps to Reproduce
I've created https://github.com/fl0rek/wasm-playground with a simple-ish reproduction case.
Difference in logging can be seen when comparing console output of
WASM_BINDGEN_USE_BROWSER=1 wasm-pack test --firefox wasm-app
vs
WASM_BINDGEN_USE_DEDICATED_WORKER=1 wasm-pack test --firefox wasm-app
In the first case there's a JsError logged and in the second one the same log does not appear. On chromium, error is logged in both cases.
Example where the JsError cannot be sent over port can be launched in the same repo by running
npm run build && npm run start in the www directory.
This again, works correctly on chromium, but fails on firefox
Expected Behavior
JsError values created inside worker on firefox behave the same as when created outside of the worker, i.e. can be logged/sent over port/etc.
Basically, the same behaviour as in chromium.
Actual Behavior
Calls which use JsError created inside a Worker behave as if they did not happen
Additional Context
I've observed same looking problem when using our own error type that calls js_sys::Error to create a js error.