Skip to content

Commit

Permalink
join handle await always propogates panic
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Hickey committed Sep 1, 2023
1 parent 0a41b99 commit 19fa65e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion crates/wasi/src/preview2/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
9 changes: 7 additions & 2 deletions crates/wasi/src/preview2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,17 @@ impl<T> From<tokio::task::JoinHandle<T>> for AbortOnDropJoinHandle<T> {
}
}
impl<T> std::future::Future for AbortOnDropJoinHandle<T> {
type Output = Result<T, tokio::task::JoinError>;
type Output = T;
fn poll(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Self::Output> {
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")),
}
}
}

Expand Down
7 changes: 2 additions & 5 deletions crates/wasi/src/preview2/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,9 @@ impl HostOutputStream for TcpWriteStream {
}

async fn write_ready(&mut self) -> Result<usize, OutputStreamError> {
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
Expand Down

0 comments on commit 19fa65e

Please sign in to comment.