Skip to content

JSPI (JavaScript Promise Integration) for WebAssembly #1093

@fgmccabe

Description

@fgmccabe

Description

JSPI (JavaScript Promise Integration) addresses a key pain point when bringing legacy code (i.e., code written in languages like C/C++) to the Web. Typically, such code uses synchronous APIs to access functionality such as reading files, downloading resources and so on. However, most modern Web APIs are asynchronous: a call to fetch does not result in the resource but a Promise of the result. It can be extremely challenging to refactor the C code to use asynchronous APIs instead of synchronous APIs.

JSPI works by suspending the WebAssembly application when a call to a Promise-bearing function is made. When the Promise is resolved the WebAssembly application is resumed with the results of the API. From the perspective of the WebAssembly application it looks like a synchronous call; from the perspective of the Web, it looks like a normal use of Promises.

This specification was standardized by the W3C WebAssembly CG in April 2025. It is currently shipping in Chrome and in Firefox.

Specification

WebAssembly Phase 4 - https://github.com/WebAssembly/js-promise-integration

web-feature

See web-platform-dx/web-features#3221

Test Links

See https://github.com/web-platform-tests/wpt/tree/master/wasm/jsapi/jspi.

Additional Signals

Standards positions:
W3C Wasm CG: voted for phase 4 on April 8, 2025 (See https://github.com/WebAssembly/meetings/blob/main/main/2025/CG-04-08.md)
WebKit: WebKit/standards-positions#422
Gecko: https://bugzilla.mozilla.org/show_bug.cgi?id=1897981
ChromeStatus: https://chromestatus.com/feature/5674874568704000

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions