rvolosatovs edited PR #11684.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
I realize that this is optional, but it's something I've been hesitant about adding in the past (a tokio dep, even optional, in Wasmtime). If possible I'd prefer to avoid this myself (and commented below about the impl)
alexcrichton created PR review comment:
These feel a bit surprising to me where a drop on the host is a trap in the guest, instead I might say we should remove these and instead rely on
impl<T, D, Fut> FutureProducer<D> for Futbelow. In my mind it's more appropriate to map a channel closure toNonein components as opposed to a trap?
rvolosatovs submitted PR review.
rvolosatovs created PR review comment:
From what I understand futures must produce a value and the
FutureProducercan only ever returnNonewhen the poll is cancelled (i.e.finishis true)@dicej is my understanding correct?
rvolosatovs created PR review comment:
Other than causing a trap on host drop we could just never resolve the future, i.e. return
Pendingwithout ever waking the runtime or produceT::default()
Perhaps these implementations are fairly WASI-specific and should just stay inwasmtime-wasi, at least for now
rvolosatovs submitted PR review.
alexcrichton submitted PR review.
alexcrichton created PR review comment:
That's right yeah, so this would map to
type Item = Option<T>, nottype Item = Tlike it does now. Basically the mismatch in Rust channel semantics and component-model channel semantics I think should show up at the type-level, not the runtime 'this trapped' level
rvolosatovs updated PR #11684.
rvolosatovs submitted PR review.
rvolosatovs created PR review comment:
I've reworked this by requiring the blanket impl futures to handle trapping directly. Although it seemed a bit dangerous to me when I originally did that, since embedders could cause a trap "on accident", I think that's fine, since these futures will actually be type bound in practice, e.g. embedders will not be able to accidentally cause a trap passing an
async { Err(String::from("interface-level error")) }toFutureReader::newcorresponding tofuture<result<_, string>>, since the Rust type system would require:Future<Output = anyhow::Result<Result<(), String>>>With this we don't need specialized producer wrappers, but rather can use
Futures directly
alexcrichton submitted PR review:
Sounds good to me, thanks!
alexcrichton merged PR #11684.
Last updated: Dec 06 2025 at 06:05 UTC