ComponentizeJS icon indicating copy to clipboard operation
ComponentizeJS copied to clipboard

componetize command does not export wasi:http/incoming-handler

Open WIGGLES-dev opened this issue 3 months ago • 1 comments

I might be just doing something wrong, but here's a simple repro.

test.js

addEventListener('fetch', (evt) => {
    console.log('fetch-event style request handling');
});

world.wit

its empty because all it wants to do is be an http server... (if I went wrong its probably here, I assume we don't have to manually export wasi:http/incoming-handler in our world)

package fetch:test;

world ui {
}

with jco 1.13

jco componetize handle.js --wit world.wit --out handle.wasm

which yields what I would expect, sands that ability to actually accept an incoing request.

all the other package definitions have been omitted, this is was I see when inspecting the component with the wit vs code extension.

package root:component;

world root {
  import wasi:io/[email protected];
  import wasi:io/[email protected];
  import wasi:io/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:cli/[email protected];
  import wasi:clocks/[email protected];
  import wasi:clocks/[email protected];
  import wasi:filesystem/[email protected];
  import wasi:filesystem/[email protected];
  import wasi:random/[email protected];
  import wasi:http/[email protected];
  import wasi:http/[email protected];
}

most importantly, the component doesn't automatically export wasi:http/outgoing-handler like the big fat

Image

would suggest....

WIGGLES-dev avatar Aug 24 '25 06:08 WIGGLES-dev

After playing around some more, I exported wasi:http/[email protected] and got it to work.

for anyone else that stumbles across this I'd like to point that if you use wit-deps to grab a specific version, you need to grab 0.2.3 (or whatever wasi version the tool is currently using) specifically. And your wit world needs to specify the version of the exported interface like.

export wasi:http/[email protected]

The above tripped me up as I kept getting error when I exported the interface without the specific version.

Its probably worthwhile including the wasi:http outgoing-handler export in the default build where fetch-event is enabled and there is not manual incoming-handler specified.

WIGGLES-dev avatar Aug 24 '25 16:08 WIGGLES-dev