Skip to content

Bump WASI support to 0.2.10 for wasi:http/incoming-handler (fetch event pattern) #299

@ericgregory

Description

@ericgregory

Summary

StarlingMonkey currently only implements wasi:http host APIs up to version 0.2.3 (host-apis/wasi-0.2.0, host-apis/wasi-0.2.2, host-apis/wasi-0.2.3). This means that JavaScript components using the Service Worker fetch event pattern cannot be compiled via jco componentize when targeting wasi:http/incoming-handler@0.2.10.

Because jco componentize embeds StarlingMonkey, and StarlingMonkey only exports wasi:http/incoming-handler@0.2.3, any WIT world that declares export wasi:http/incoming-handler@0.2.10 fails at the component encoding step.

This is a blocker for users who need to target WASI 0.2.10, for example to run components on wasmtime serve (wasmtime 39+), which has moved on from 0.2.3.

See also: bytecodealliance/ComponentizeJS#313

Steps to Reproduce

Starting from the jco http-server-fetch-handler example:

1. Create the component source

component.js:

addEventListener("fetch", (event) =>
  event.respondWith(
    (async () => {
      return new Response("Hello World");
    })(),
  ),
);

wit/component.wit (bumped to 0.2.10):

package example:http-server-fetch-handler;

world component {
    export wasi:http/incoming-handler@0.2.10;
}

package.json:

{
  "name": "http-server-fetch-handler",
  "type": "module",
  "scripts": {
    "build": "jco componentize component.js --wit wit/ --world-name component --out component.wasm"
  },
  "dependencies": {
    "@bytecodealliance/jco": "^1.15.0"
  }
}

2. Install dependencies and fetch WIT deps

npm install
wkg wit fetch

3. Attempt to build

npx jco componentize component.js --wit wit/ --world-name component --out component.wasm

Expected Behavior

The component compiles successfully, producing a component.wasm that exports wasi:http/incoming-handler@0.2.10 and can be served with wasmtime serve.

Actual Behavior

Componentization fails with the following error:

(jco componentize) ComponentError: failed to encode a component from module
$failed to decode world from module

Caused by:
    0: module was not valid
    1: failed to find export of interface `wasi:http/incoming-handler@0.2.10` function `handle`

The root cause is that StarlingMonkey's embedded module only exports wasi:http/incoming-handler@0.2.3. Since jco componentize uses StarlingMonkey to provide the fetch event handler glue, the version mismatch causes the component encoding to fail.

Working Baseline

The same component compiles and runs successfully when targeting wasi:http/incoming-handler@0.2.3:

export wasi:http/incoming-handler@0.2.3;
$ npx jco componentize component.js --wit wit/ --world-name component --out component.wasm
OK Successfully written component.wasm.

$ wasmtime serve -S cli=y -S http=y component.wasm
Serving HTTP on http://0.0.0.0:8080/

$ curl http://localhost:8080/
Hello World

Environment

  • @bytecodealliance/jco: 1.16.1
  • @bytecodealliance/componentize-js: 0.19.3
  • wasmtime: 39.0.1
  • wkg: 0.13.0
  • Node.js: v24.9.0
  • Platform: macOS (Darwin 25.2.0, aarch64)

Request

Please add a host-apis/wasi-0.2.10 implementation to StarlingMonkey so that the fetch event pattern can be used with wasi:http/incoming-handler@0.2.10. This will unblock downstream users of jco componentize who need to target current WASI versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions