Stream: ComponentizeJS

Topic: fetchEvent versus manual incomingHandler implementations


view this post on Zulip Victor Adossi (Jul 08 2025 at 18:12):

I think I've found a problem with the current way we try to handle wasi:incoming-handler... Let me try to sum things up:

Here are the problems (I think) with this situation:

  1. StarlingMonkey always exposes wasi:http/incoming-handler, because the user could use the fetchEvent integration at any time :shrug:

  2. Without parsing the JS (like we used to), we do not know if someone has implemented wasi:http/incoming-handler themselves. :thinking:

There are 4 scenarios:

  1. user does no HTTP, no wasi export :check:
  2. user does HTTP manually, w/export wasi:http/incoming-handler :check:
  3. user does HTTP manually, no wasi export :no_signal: (this is invalid/doesn't make sense)
  4. user does HTTP with fetchEvent, no wasi export :cross_mark:

  5. user does HTTP with fetchEvent, w/ export wasi:http/incoming-handler :cross_mark:

I'm currently mulling two ways to solve this:

1.Always export wasi:http/incoming-handler when http feature is on

- This is just a little bit similar to what we hand before, i.e. requiring splice-bindings to know about features
- This solution is somewhat unsatisfying but is the simplest and isn't unreasonable, as the HTTP feature does indicate that there should be inclusion of the interface

  1. Re-add parsing of the JS (no rewriting) via es-module-lexer to figure out which case we're in

Any feedback would be appreciated. I'm leaning towards (1) for expedience (and I'm not sure it's worth re-introducing the additional dependencies to do (2) just yet, though it's the more satisfying solution).

JS -> WebAssembly Component. Contribute to bytecodealliance/ComponentizeJS development by creating an account on GitHub.
This is a pretty large patch containing a whole bunch of changes. They're not really all related, but are hard to disentangle now, after being introduced while I worked on enabling debugging of...
This commit removes the ignored handling of wasi:http/incoming-handler which breaks components that have manually implemented the handle export. This change was introduced during the recent overhau...
A collection of high-performance JavaScript tools written in Rust

view this post on Zulip Victor Adossi (Jul 08 2025 at 18:20):

On second thought, I really am starting to like the oxc based solution here -- the node bindings are quite ergonomic and look like they'll work nicely to help figure out top level statements and imports/exports.

This would require of course introducing a new non-trivial (but production ready, IMO) dependency to componentize-js -- thoughts, @Till Schneidereit ?

Oxc Parser Node API. Latest version: 0.76.0, last published: 8 hours ago. Start using oxc-parser in your project by running `npm i oxc-parser`. There are 62 other projects in the npm registry using oxc-parser.

view this post on Zulip Tomasz Andrzejak (Jul 08 2025 at 19:48):

Hey Victor! Thanks for the write up. I was banging my head against the wall today trying to use local componentize-js. Everything appears to work correctly with the published version 18.2 for my use case, which is installing a handler using addEventListener("fetch"). However, when I switch to the local componentize-js for the same js code, I get this error:

Error: Unable to extract expected exports list
Error: "source.js" does not export a "incomingHandler" interface as expected by the world.
  Try defining it by its alias:
  export const incomingHandler = {};

I guess this is exactly the issue you described here. Do you happen to know which commit introduced this breaking change?

view this post on Zulip Victor Adossi (Jul 09 2025 at 11:29):

Yup, so the commit that introduced this change is this one (and the related PR):

https://github.com/bytecodealliance/ComponentizeJS/commit/54ab08566d0cdf7cd8db8483bc5c02d9e35e3ffb
https://github.com/bytecodealliance/ComponentizeJS/pull/218

The problem with 18.2 is that it breaks existing wasi:http implementations -- this is something that should have been solved before 18.2 was released, and why Jco has been stuck on 0.17.0 for a while now.

This commit removes the ignored handling of `wasi:http/incoming-handler` which breaks components that have manually implemented the `handle` export. Signed-off-by: Victor Adossi <vadossi@cosmon...
This commit removes the ignored handling of wasi:http/incoming-handler which breaks components that have manually implemented the handle export. This change was introduced during the recent overhau...

view this post on Zulip Victor Adossi (Jul 10 2025 at 17:03):

PR to fix this is up -- works on my machine :tm:

https://github.com/bytecodealliance/ComponentizeJS/pull/247

This commit updates the componentize-js code to support both fetchEvent and manual based HTTP. To make this possible we needed to re-introduce a few things: A feature that represents fetch-event A...

view this post on Zulip Ralph (Jul 10 2025 at 17:44):

nice move!


Last updated: Dec 06 2025 at 07:03 UTC