diff --git a/crates/wasi/src/preview2/pipe.rs b/crates/wasi/src/preview2/pipe.rs index 02e2ca0962e2..34eb8a34f03a 100644 --- a/crates/wasi/src/preview2/pipe.rs +++ b/crates/wasi/src/preview2/pipe.rs @@ -666,10 +666,13 @@ mod test { assert_eq!(len, chunk.len()); assert_eq!(state, StreamState::Open); - // But I expect this to block additional writes: + // It is possible for subsequent writes to be refused, but it is nondeterminstic because + // the worker task consuming them is in another thread: let (len, state) = writer.write(chunk.clone()).unwrap(); - assert_eq!(len, 0); assert_eq!(state, StreamState::Open); + if !(len == 0 || len == chunk.len()) { + unreachable!() + } tokio::time::timeout(REASONABLE_DURATION, writer.ready()) .await diff --git a/crates/wasi/src/preview2/preview2/io.rs b/crates/wasi/src/preview2/preview2/io.rs index ed03fa9e77b0..ad41d0c97628 100644 --- a/crates/wasi/src/preview2/preview2/io.rs +++ b/crates/wasi/src/preview2/preview2/io.rs @@ -412,7 +412,7 @@ pub mod sync { stream: OutputStream, bytes: Vec, ) -> Result<(u64, streams::StreamStatus), streams::Error> { - in_tokio(async { AsyncHost::write(self, stream, bytes).await }) + in_tokio(async { AsyncHost::blocking_write(self, stream, bytes).await }) .map(|(a, b)| (a, b.into())) .map_err(streams::Error::from) }