getditto/safer_ffi

Handle non-panic Tokio task termination

sameer opened this issue · 0 comments

When joining with a Tokio task, JoinError can be a panic or a cancellation. Safer FFI assumes it will be a panic, which causes another panic if it is actually a cancellation.

I am not sure how a cancellation should be handled here, but it is distinct.

Error:  2023-11-23T12:37:44.748Z: Panic: `JoinError` reason is not a panic.: JoinError::Cancelled(Id(16584))

   12: core::result::Result<T,E>::expect
             at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1070:23
  13: tokio::runtime::task::error::JoinError::into_panic
             at /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.33.0/src/runtime/task/error.rs:87:9
  14: <tokio::runtime::handle::Handle as safer_ffi::dyn_traits::futures::executor::FfiFutureExecutor>::dyn_spawn_blocking::{{closure}}::{{closure}}
             at /runner/_work/safer-ffi/src/dyn_traits/futures/executor.rs:174:53
  15: core::result::Result<T,E>::unwrap_or_else