AI Briefing
Sign in

Cloudflare adds experimental Emscripten support for Rust on Workers

·2026.09.28 22:00

Key point

The update allows running complex Rust applications, including a Minecraft server, directly on Cloudflare Workers using the wasm32-unknown-emscripten target.

Details

Cloudflare has announced an experimental preview of first-class support for the Emscripten wasm32-unknown-emscripten Rust compiler target within the wasm-bindgen toolchain. This integration enables native Rust code, including applications built on the Tokio async runtime, to run directly on Cloudflare Workers and other WebAssembly environments.

Toolchain Interoperability

The feature resolves a long-standing conflict between Emscripten and wasm-bindgen, which previously competed to manage JavaScript bindings and module loading. By collaborating with Google’s Portable Toolchains team, the new workflow allows Emscripten to drive the build while wasm-bindgen produces portable JavaScript bindings, enabled by the -sWASM_BINDGEN configuration.

Tokio Runtime Integration

To support Tokio’s async model within the single-threaded JavaScript event loop, Cloudflare implemented two approaches:

  • JSPI (JavaScript Promise Integration): Maps Tokio’s parking semantics to JSPI stack suspensions, requiring careful thread-local context swapping to prevent runtime panics.
  • LocalEventLoop: A proposed design that splits Tokio’s loop into an explicit drive() operation and a host-owned Waker, allowing the host event loop to interleave its own work with Tokio’s without blocking.

Networking and Sockets

To support Tokio’s I/O driver, which relies on epoll, Cloudflare contributed over 40 pull requests to Emscripten to create the -sNODERAWSOCKETS layer. This bridges Emscripten’s virtualization layer to the node:net API, enabling TCP, UDP, and Unix sockets on Workers.

Demonstration: Minecraft on Workers

To validate the stack, engineers ported Pumpkin, a Rust Minecraft server, to run inside a Durable Object. The port converted Pumpkin’s multi-threaded architecture into cooperative Tokio tasks and used a custom file system backend to store world data in the Durable Object’s SQLite database. The server successfully handles multiplayer connections via Workers TCP ingress.

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.