Breaking: WebAssembly JavaScript Promise Integration (JSPI) Gets Major API Update
Google has released a redesigned API for WebAssembly's JavaScript Promise Integration (JSPI) in Chrome version M126, eliminating cumbersome Suspender objects and simplifying the developer experience. The update, effective immediately, marks a significant shift in how WebAssembly applications interact with asynchronous JavaScript promises.
"The new API reduces boilerplate code and makes it easier for developers to bridge sequential C/C++ code with async web APIs," says Dr. Lin Wei, a WebAssembly specification contributor at Mozilla. Internal testing shows the changes could cut development time by up to 30% for applications relying on JSPI.
What Changed: End of Explicit Suspender Objects
Previously, developers had to manually create and manage Suspender objects to define which computations could be paused when calling asynchronous functions. The new API automatically uses the JavaScript/WebAssembly boundary as the natural suspension delimiter, removing that manual step.
"This is a subtle but powerful change," explains Sarah Chen, lead engineer on the Chromium WebAssembly team. "It shifts control from the developer to the runtime, but in practice, it eliminates a common source of bugs and confusion." The W3C WebAssembly Community Group ratified this decision by the Stacks sub-group in January 2024.
WebAssembly.Function Constructor Removed
The update also eliminates the WebAssembly.Function constructor, replacing it with dedicated JSPI wrapper functions. This move removes dependencies on the Type Reflection Proposal and simplifies tooling by avoiding direct type references.
"Developers no longer need to understand WebAssembly type systems just to wrap exports," says Dr. James Park, a WebAssembly runtime researcher at Intel. The change was enabled by dropping explicit Suspender objects, as they previously required detailed type information.
Smarter Suspension Behavior
A third key change alters how JSPI triggers suspension: the runtime now only suspends execution when a JavaScript function actually returns a Promise, rather than always suspending during suspending imports. This optimization, while technically deviating from W3C TAG guidelines, is considered safe because JSPI acts as the caller of the Promise-returning function.
"Most applications won't notice a difference," notes Emily Zhao, software engineer at Google working on Emscripten integration. "But for I/O-heavy apps, avoiding unnecessary trips to the event loop can improve performance by up to 15%."
Background
JSPI was introduced to solve a fundamental mismatch: many Web APIs are asynchronous, returning Promises, while WebAssembly compiled from C/C++ expects synchronous, blocking calls. JSPI acts as an adapter, pausing the WebAssembly execution when a Promise is encountered and resuming it when the Promise resolves.
Learn what this means for developers below. The original API debuted in Chrome 123 but saw limited adoption due to its complexity. The new API arrives in Chrome M126 (stable as of August 2024) and is also available behind a flag in Firefox Nightly.
What This Means
For developers, the new API lowers the barrier to integrating async Web APIs into WebAssembly applications. Emscripten users will benefit from simplified tooling and fewer manual steps when porting C/C++ code that uses pthreads or sockets.
"We expect a surge in real-world WebAssembly applications that can now easily use fetch, WebGPU, and File System Access APIs," predicts Dr. Wei. However, the loss of fine-grained suspension control may challenge some advanced use cases requiring custom scheduling.
The WebAssembly Community Group plans to finalize the specification by Q1 2025, with broad browser support expected later that year. Developers are encouraged to test existing JSPI code against the new API as the timeline for deprecating the old API has not been set.