diff --git a/crates/wasi/src/preview2/filesystem.rs b/crates/wasi/src/preview2/filesystem.rs index a8e74ec2adb1..f99b6ab2d9af 100644 --- a/crates/wasi/src/preview2/filesystem.rs +++ b/crates/wasi/src/preview2/filesystem.rs @@ -266,7 +266,6 @@ impl HostOutputStream for FileOutputStream { match std::pin::Pin::new(&mut self.task) .take_output() .expect("just awaited for MaybeDone completion") - .expect("FileOutputStream worker task panicked") { Ok(()) => Ok(FILE_WRITE_CAPACITY), Err(e) => { diff --git a/crates/wasi/src/preview2/mod.rs b/crates/wasi/src/preview2/mod.rs index bee396b832a2..d4e1ba998914 100644 --- a/crates/wasi/src/preview2/mod.rs +++ b/crates/wasi/src/preview2/mod.rs @@ -180,12 +180,17 @@ impl From> for AbortOnDropJoinHandle { } } impl std::future::Future for AbortOnDropJoinHandle { - type Output = Result; + type Output = T; fn poll( mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, ) -> std::task::Poll { - std::pin::Pin::new(&mut self.as_mut().0).poll(cx) + use std::pin::Pin; + use std::task::Poll; + match Pin::new(&mut self.as_mut().0).poll(cx) { + Poll::Pending => Poll::Pending, + Poll::Ready(r) => Poll::Ready(r.expect("child task panicked")), + } } } diff --git a/crates/wasi/src/preview2/tcp.rs b/crates/wasi/src/preview2/tcp.rs index e85aacc33af6..d1117cf8e555 100644 --- a/crates/wasi/src/preview2/tcp.rs +++ b/crates/wasi/src/preview2/tcp.rs @@ -184,12 +184,9 @@ impl HostOutputStream for TcpWriteStream { } async fn write_ready(&mut self) -> Result { - if self.write_handle.is_some() { - self.write_handle - .as_mut() - .unwrap() + if let Some(handle) = &mut self.write_handle { + handle .await - .expect("TcpWriteStream worker panicked") .map_err(|e| OutputStreamError::LastOperationFailed(e.into()))?; // Only clear out the write handle once the task has exited, to ensure that