Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 264c30a

Browse files
dicejlukewagner
andcommitted
fix another stream/future ABI spec discrepancy
This fixes another case where we weren't returning the correct status for closed futures and streams. Thanks to Luke for the updated test case. Fixes #161 Co-authored-by: Luke Wagner <mail@lukewagner.name> Signed-off-by: Joel Dice <joel.dice@fermyon.com>
1 parent ac09ef4 commit 264c30a

4 files changed

Lines changed: 253 additions & 103 deletions

File tree

crates/misc/component-async-tests/tests/scenario/transmit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::future::Future;
22
use std::pin::Pin;
33
use std::sync::{Arc, Mutex};
44

5-
use anyhow::{Result, anyhow};
5+
use anyhow::{anyhow, Result};
66
use futures::{
77
future::{self, FutureExt},
88
stream::{FuturesUnordered, TryStreamExt},
@@ -17,7 +17,7 @@ use wasmtime_wasi::p2::WasiCtxBuilder;
1717

1818
use component_async_tests::transmit::bindings::exports::local::local::transmit::Control;
1919
use component_async_tests::util::{compose, config, test_run, test_run_with_count};
20-
use component_async_tests::{Ctx, sleep, transmit};
20+
use component_async_tests::{sleep, transmit, Ctx};
2121

2222
use cancel::exports::local::local::cancel::Mode;
2323

crates/wasmtime/src/runtime/component/concurrent.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,15 @@ enum Event {
157157
},
158158
StreamRead {
159159
code: ReturnCode,
160-
handle: u32,
161-
ty: TypeStreamTableIndex,
160+
pending: Option<(TypeStreamTableIndex, u32)>,
162161
},
163162
StreamWrite {
164163
code: ReturnCode,
165164
pending: Option<(TypeStreamTableIndex, u32)>,
166165
},
167166
FutureRead {
168167
code: ReturnCode,
169-
handle: u32,
170-
ty: TypeFutureTableIndex,
168+
pending: Option<(TypeFutureTableIndex, u32)>,
171169
},
172170
FutureWrite {
173171
code: ReturnCode,
@@ -4291,7 +4289,10 @@ impl Waitable {
42914289
/// the state of the stream or future.
42924290
fn on_delivery(&self, instance: &mut ComponentInstance, event: Event) {
42934291
match event {
4294-
Event::FutureRead { ty, handle, .. }
4292+
Event::FutureRead {
4293+
pending: Some((ty, handle)),
4294+
..
4295+
}
42954296
| Event::FutureWrite {
42964297
pending: Some((ty, handle)),
42974298
..
@@ -4313,7 +4314,10 @@ impl Waitable {
43134314
_ => unreachable!(),
43144315
};
43154316
}
4316-
Event::StreamRead { ty, handle, .. }
4317+
Event::StreamRead {
4318+
pending: Some((ty, handle)),
4319+
..
4320+
}
43174321
| Event::StreamWrite {
43184322
pending: Some((ty, handle)),
43194323
..

0 commit comments

Comments
 (0)