Skip to content

Conversation

@alexcrichton
Copy link
Member

Match the WASIp2 stdio implementation and "lie" about stdio actually being async. Instead of using Tokio's primitives use the std::io primitives which will block the current program while the output is produced. This matches WASIp2 semantics and we always have the option of making this more async in the future (or even have it as a runtime flag). This avoids the need to call poll_flush in stdio unconditionally in the wasi:cli implementation which didn't feel quite right.

Match the WASIp2 stdio implementation and "lie" about stdio actually
being async. Instead of using Tokio's primitives use the `std::io`
primitives which will block the current program while the output is
produced. This matches WASIp2 semantics and we always have the option of
making this more async in the future (or even have it as a runtime
flag). This avoids the need to call `poll_flush` in stdio
unconditionally in the `wasi:cli` implementation which didn't feel quite
right.
@alexcrichton alexcrichton requested review from a team as code owners September 5, 2025 15:42
@alexcrichton alexcrichton requested review from dicej and removed request for a team September 5, 2025 15:42
Copy link
Contributor

@dicej dicej left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me, and embedders still have the option of configuring their WasiCtx with stdio streams that use tokio::io::std{out,err}() (or an auto-flushing wrapper around them) to get the previous behavior, if desired.

@alexcrichton alexcrichton added this pull request to the merge queue Sep 5, 2025
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Sep 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 5, 2025
It's got a shorter command line length limit
@alexcrichton alexcrichton added this pull request to the merge queue Sep 5, 2025
Merged via the queue into bytecodealliance:main with commit 2fd0c7b Sep 5, 2025
44 checks passed
@alexcrichton alexcrichton deleted the wasip3-stdio-blocking branch September 5, 2025 18:06
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Sep 8, 2025
* wasip3: Update std{out,err} implementation

Match the WASIp2 stdio implementation and "lie" about stdio actually
being async. Instead of using Tokio's primitives use the `std::io`
primitives which will block the current program while the output is
produced. This matches WASIp2 semantics and we always have the option of
making this more async in the future (or even have it as a runtime
flag). This avoids the need to call `poll_flush` in stdio
unconditionally in the `wasi:cli` implementation which didn't feel quite
right.

* One fewer run for Windows

It's got a shorter command line length limit
alexcrichton added a commit that referenced this pull request Sep 8, 2025
* wasip3: Update std{out,err} implementation (#11618)

* wasip3: Update std{out,err} implementation

Match the WASIp2 stdio implementation and "lie" about stdio actually
being async. Instead of using Tokio's primitives use the `std::io`
primitives which will block the current program while the output is
produced. This matches WASIp2 semantics and we always have the option of
making this more async in the future (or even have it as a runtime
flag). This avoids the need to call `poll_flush` in stdio
unconditionally in the `wasi:cli` implementation which didn't feel quite
right.

* One fewer run for Windows

It's got a shorter command line length limit

* wasip3: Refactor file in/out streams (#11619)

* Deduplicate write/append streams
* Deduplicate poll-the-task and spawn-the-task-then-poll
* Explicitly ignore the `finish` flag

* Support store-access in `bindgen!` generated imports  (#11628)

* Support store-access in `bindgen!` generated imports

This commit adds support to accessing the store in `bindgen!`-generated
import functions in traits. Since the inception of `bindgen!` this has
never been possible and access to the store requires manually working
with `Linker`, for example. This is not easy to do because it requires
surgically editing code or working around what bindings generation parts
you do want.

The implementation here is a small step away from what
component-model-async has already implemented for async functions.
Effectively it's a small extension of the `*WithStore` traits to also
have synchronous functions with `Access` parameters instead of `async`
functions with an `Accessor` parameter.

This is something we're going to want for the WASIp3 implementation
where I've noticed some resource destructors are going to want access to
the store to close out streams and such and this'll provide the bindings
necessary for that.

Closes #11590

* Update test expectations

* feat(p3): implement `wasi:http` (#11440)

* feat(p3-http): begin implementation

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* feat(p3-http): implement incoming HTTP

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* feat(p3-http): switch to new API

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* feat(p3-http): begin outgoing implementation

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* test(p3-http): test invalid header

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* fix(p3-http): await I/O if future receiver dropped

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>

* Re-internalize some fields

Try to keep fields private and use public ctors instead.

* Uncomment `p3_http_outbound_request_content_length` test

It's still semi-failing, but defer that to #11631

* Get tests passing CI again

---------

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Alex Crichton <alex@alexcrichton.com>

* Tune new "much stdout" test for runtime (#11635)

On Pulley platforms this test is taking 40+ minutes in CI. Locally it
took 2 minutes to complete. After this change it should still roughly
test the same thing but takes less than 100ms to complete locally.

---------

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
Co-authored-by: Roman Volosatovs <rvolosatovs@users.noreply.github.com>
bongjunj pushed a commit to prosyslab/wasmtime that referenced this pull request Oct 20, 2025
* wasip3: Update std{out,err} implementation

Match the WASIp2 stdio implementation and "lie" about stdio actually
being async. Instead of using Tokio's primitives use the `std::io`
primitives which will block the current program while the output is
produced. This matches WASIp2 semantics and we always have the option of
making this more async in the future (or even have it as a runtime
flag). This avoids the need to call `poll_flush` in stdio
unconditionally in the `wasi:cli` implementation which didn't feel quite
right.

* One fewer run for Windows

It's got a shorter command line length limit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi Issues pertaining to WASI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants