Making Rust Workers reliable: panic and abort recovery in wasmâbindgen
Blog post from Cloudflare
Cloudflare Workers have improved their handling of errors in Rust Workers by advancing error recovery mechanisms for WebAssembly (Wasm) using the wasm-bindgen toolchain. Historically, issues like panics and aborts in Rust Workers could lead to a poisoned instance, affecting subsequent requests. The text details the introduction of panic=unwind support, which enables the recovery of panics without losing state, leveraging the WebAssembly Exception Handling proposal. This advancement allows destructors to run correctly, ensuring panics are caught and surfaced as JavaScript PanicError exceptions, with promises being rejected accordingly. Additionally, abort recovery mechanisms have been developed to detect and recover from aborts, ensuring that invalid states do not persist and do not lead to cascading failures. These improvements, incorporated into the wasm-bindgen project, aim to enhance the stability of Rust Workers and contribute to a more robust WebAssembly ecosystem, with ongoing efforts to transition these features to stable Rust releases.