Stream: general

Topic: how to use catch_unwind in webassembly


view this post on Zulip Hoping White (Apr 08 2025 at 07:25):

I have tried to build WASM for wasm32-unknown-unknown but found that catch_unwind is not working properly. How do I use catch_unwind in WASM? Do I need wasm32-wasmi to make catch_unwind work?

view this post on Zulip bjorn3 (Apr 08 2025 at 09:40):

Wasm exception support isn't yet supported by wasmtime. And to compile for wasm exceptions with rustc, I think you currently need to do something likeRUSTFLAGS="-Cpanic=unwind" cargo build -Zbuild-std --target wasm32-unknown-unknown with nightly rustc to rebuild the standard library with exception support.

view this post on Zulip Hoping White (Apr 08 2025 at 09:41):

Does wasmtime have a time plan for this feature?

view this post on Zulip bjorn3 (Apr 08 2025 at 10:36):

Yes, it is currently being implemented.

view this post on Zulip bjorn3 (Apr 08 2025 at 10:37):

You will likely need nightly rustc for a while though.

view this post on Zulip Hoping White (Apr 08 2025 at 10:48):

bjorn3 said:

Yes, it is currently being implemented.

Thanks for the instruction. I managed to build an unwind wasm. But when I ran it with wasmtime, I got an error exceptions proposal not enabled (at offset 0xe2). So will exception support be added in wasmtime soon?

view this post on Zulip bjorn3 (Apr 08 2025 at 11:44):

Yeah, that is what I meant. It currently isn't implemented yet, but someone is working on the Cranelift changes necessary for implementing exception support in Wasmtime.


Last updated: Dec 06 2025 at 05:03 UTC