Skip to content

fix(preview2-shim): throw invalid would-block from browser incoming-body read - #2043

Merged
vados-cosmonic merged 8 commits into
bytecodealliance:mainfrom
eduardomourar:fix/preview2-shim-browser-would-block
Sep 6, 2026
Merged

fix(preview2-shim): throw invalid would-block from browser incoming-body read#2043
vados-cosmonic merged 8 commits into
bytecodealliance:mainfrom
eduardomourar:fix/preview2-shim-browser-would-block

Conversation

@eduardomourar

@eduardomourar eduardomourar commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #2042.

wasi:io/streams stream-error only has closed and last-operation-failed variants - there's no would-block. The browser IncomingBody's non-blocking read() threw { tag: "would-block" } whenever no data was buffered yet, which JSPI-driven callers (e.g. wstd's Reactor loop) can't lower into a valid stream-error, silently swallowing the failure and hanging forever instead of surfacing an error. Return an empty array instead, per spec, and let the existing subscribe()/wait mechanism handle backpressure like it already does for blockingRead().

vados-cosmonic
vados-cosmonic previously approved these changes Sep 6, 2026

@vados-cosmonic vados-cosmonic left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

eduardomourar and others added 7 commits September 6, 2026 16:29
`wasi:io/streams` stream-error only has `closed` and `last-operation-failed`
variants - there's no `would-block`. The browser IncomingBody's non-blocking
read() threw `{ tag: "would-block" }` whenever no data was buffered yet, which
JSPI-driven callers (e.g. wstd's Reactor loop) can't lower into a valid
stream-error, silently swallowing the failure and hanging forever instead of
surfacing an error. Return an empty array instead, per spec, and let the
existing subscribe()/wait mechanism handle backpressure like it already does
for blockingRead().
@vados-cosmonic
vados-cosmonic force-pushed the fix/preview2-shim-browser-would-block branch from 05fd435 to ced83ab Compare September 6, 2026 07:29
@vados-cosmonic
vados-cosmonic added this pull request to the merge queue Sep 6, 2026
Merged via the queue into bytecodealliance:main with commit 9d26ff6 Sep 6, 2026
58 checks passed
@eduardomourar
eduardomourar deleted the fix/preview2-shim-browser-would-block branch September 6, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

preview2-shim: input-stream read method throws invalid would-block tag

2 participants