libsmol opened PR #14987 from libsmol:tcp-read-readiness to bytecodealliance:main:
Fixes #14986.
TcpReceiveStream::poll_readyreturned tokio's cached read readiness, which tokio only clears once an operation returnsWouldBlock. Right after a connection is set up that readiness can already be set although nothing has been received, so a WASIp2 TCP input stream could report ready before any data arrived (details in the issue).This makes
poll_readypeek a single byte instead.poll_peekwaits for data, the end of the stream or an error, and when there's nothing to read it clears tokio's readiness and registers the waker as before.poll_readis unchanged.Testing
p2_tcp_streamsgainstest_tcp_input_stream_should_not_be_ready_without_data, which checks that neither side of a fresh connection is ready, that the client becomes ready once the server writes, and that it's no longer ready after the data has been read. Onmainit fails in bothp2::sync::p2_tcp_streamsandp2::async_::p2_tcp_streams, and passes with this change.cargo test -p wasmtime-wasipasses exceptp3::p3_sockets_udp_connect, which fails the same way without this change in my environment (Linux aarch64 under OrbStack, where the loopback and public addresses end up on the same local interface).cargo clippy -p wasmtime-wasi --all-targetsis clean.- In an embedder using
wasmtime_wasi::p2::add_to_linker_sync, wasi-libc'spoll()on an idle accepted connection now waits for its timeout instead of returning 1 at once.
This pull request was prepared by an AI coding assistant (Claude Code, running Anthropic's Claude Opus 5.5) on behalf of the libsmol project. We've tested it as described above, but we're happy to rework it if you'd prefer a different approach.
:robot: Generated with Claude Code
libsmol removed the review request for wasmtime-wasi-reviewers from PR #14987.
libsmol requested wasmtime-wasi-reviewers for a review on PR #14987.
libsmol requested rvolosatovs for a review on PR #14987.
libsmol removed the review request for wasmtime-core-reviewers from PR #14987.
libsmol requested cfallin for a review on PR #14987.
libsmol requested wasmtime-core-reviewers for a review on PR #14987.
tschneidereit commented on PR #14987:
Closing this for the same reason as the issue it's meant to close.
:cross_mark: tschneidereit closed without merge PR #14987.
Last updated: Oct 31 2026 at 23:03 UTC