« All posts

Cloudflare Workers Gains Experimental Native Rust and Tokio Support via Emscripten

Cloudflare adds experimental Emscripten target support to wasm-bindgen, enabling native Rust and Tokio async apps to run on Workers.

Cloudflare has announced experimental preview support for the wasm32-unknown-emscripten target in wasm-bindgen, the open-source toolchain behind Rust WebAssembly on Workers. Developed jointly with Google's Portable Toolchains team over more than a year, the work introduces a new -sWASM_BINDGEN configuration that lets Emscripten's and wasm-bindgen's binding layers coexist in a single build, resolving a long-standing conflict where each toolchain assumed sole control over JavaScript generation.

The result is markedly better library compatibility for Rust Workers: low-level crates like libc, socket2, and Mio needed only minor patches to recognize the Emscripten target, and many others worked unmodified. As a demonstration, engineers ran a native Rust Minecraft server (Pumpkin) inside a Durable Object using real TCP sockets over Tokio.

The harder problem was reconciling Tokio's thread-parking-based async model with Workers' single-threaded JS event loop, where blocking calls can't stall the loop. Cloudflare contributed patches enabling both a WebAssembly JavaScript Promise Integration (JSPI) approach — which maps naturally onto Tokio's parking semantics but requires careful thread-local handling across stack switches — and direct event-loop integration in Tokio itself, with the first Emscripten target support already merged upstream. For engineers, this materially widens the pool of Rust libraries and async code that can run natively and performantly on Workers.

This synthesis was produced from its source by AI; there is no human editor or manual review step. How we work