Skip to content

CONCEPT Cited by 1 source

WebAssembly Exception Handling

Definition

WebAssembly Exception Handling is a Wasm specification proposal adding structured exception primitives — try, catch, catch_all, throw, rethrow — to the Wasm instruction set. Without it, Wasm had no portable way to unwind; the only failure primitive was unreachable, which traps and exits to the embedder.

The proposal reached wide engine support in 2023 and is the primitive underneath Rust's panic=unwind on wasm32-unknown-unknown and C++ exceptions compiled to Wasm.

Two variants

During the proposal's development a late-stage specification change produced two wire-compatible variants:

As of the 2026-04-22 Cloudflare post, Rust's Wasm targets still default to the legacy variant; Cloudflare is working to make modern the default "next year."

Engine support for modern EH

Runtime Version Released
V8 (systems/v8-javascript-engine) 13.8.1 2025-04-28
workerd (systems/workerd) v1.20250620.0 2025-06-19
Chrome 138 2025-06-28
Firefox 131 2024-10-01
Safari 18.4 2025-03-31
Node.js (systems/nodejs) 25.0.0 2025-10-15

Node.js backport as enabling step

Node.js 24 LTS was the constraint — its release schedule would have kept the ecosystem on legacy EH until April 2028. Cloudflare backported modern EH to Node.js 24 and Node.js 22 so modern EH becomes viable as a default target. "This should allow the modern Exception Handling proposal to become the default target next year." Canonical wiki instance of patterns/upstream-the-fix at the Wasm-engine layer.

What wasm-bindgen uses EH for

Cloudflare's 2026-04 work in systems/wasm-bindgen leverages Wasm EH to:

  1. Compile Rust destructors into catch_all blocks that fire on unwind.
  2. Compile std::panic::catch_unwind(|| …) into nested try / catch pairs.
  3. Surface panics at the Rust↔JS boundary as JavaScript PanicError exceptions.
  4. Introduce an Exception.Tag for foreign exceptions to distinguish recoverable unwinds from non-unwindable aborts (see concepts/abort-recovery).

"Since our foreign exception handling was directly using raw WAT-level (WebAssembly text format) Exception Handling instructions already, we found it easier to implement exception tags for foreign exceptions to distinguish them from aborting non-unwind-safe exceptions."

Seen in

Last updated · 510 distilled / 1,221 read