bytecodealliance / bytecodealliance/StarlingMonkey

State clearing after FetchEvent handling

Open
#247 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C
Stars
288
Forks
57
PR merge metrics
No merged PRs in 30d

Description

StarlingMonkey currently cannot reuse component instances that perform HTTP request handling with the `FetchEvent` handler.

While production recommendation for WebAssembly components often centers around one (new) instance per request, alternatives like`wasi:http` handling do *not* suffer from this same limitation, and can handle multiple requests.

Regardless of production recommendation, StarlingMonkey should be able to handle more than one web request.

The error logs around this issue look something like the following:

```
Exception while dispatching FetchEvent

component.js:921:13 uncaught exception: InvalidStateError: FetchEvent#respondWith can't be called twice on the same event
```

The *second* request (that encounters the above error) hangs and never returns.

To reproduce this issue:
1. Create a component that handles a request
2. Set up a host embedding in which the component instance is *not* destroyed after serving a single request
3. Send more than one request

More concretely, you can reproduce this behavior with one of Jco's example projects:
https://github.com/bytecodealliance/jco/tree/main/examples/components/http-server-hono

After early debugging (thanks @andreiltd !) the issue seems to be related to the clearing out of relevant state after a `FetchEvent` is called in the current code.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.