You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The backoff::future::retry works well on wasm32-unknown-unknown with tokio as long as there is never an error that triggers the backoff. Once a backoff is triggered the TokioSleeper is used and tokio::time is used.
The problem with this is that on wasm32-unknown-unknown with no time source, a panic is caused by this attempt to sleep with tokio. This is because tokio only uses the std time which isn't implemented. The following panic will be seen:
panicked at 'time not implemented on this platform', library/std/src/sys/wasm/../unsupported/time.rs:13:9
Stack:
<?>.wasm-function[console_error_panic_hook::Error::new::hf6b67bbb1aa769d8]@[wasm code]
<?>.wasm-function[console_error_panic_hook::hook_impl::h1826ea7fdfe0e730]@[wasm code]
<?>.wasm-function[console_error_panic_hook::hook::ha2b94ff4b371fbc5]@[wasm code]
<?>.wasm-function[core::ops::function::Fn::call::h80ff1f496bb96ef1]@[wasm code]
<?>.wasm-function[std::panicking::rust_panic_with_hook::h70a0e195f4db2a29]@[wasm code]
<?>.wasm-function[std::panicking::begin_panic_handler::{{closure}}::hdcfc819ce836829e]@[wasm code]
<?>.wasm-function[std::sys_common::backtrace::__rust_end_short_backtrace::h53cabafab5b09ada]@[wasm code]
<?>.wasm-function[rust_begin_unwind]@[wasm code]
<?>.wasm-function[core::panicking::panic_fmt::h751be80779d42b53]@[wasm code]
<?>.wasm-function[std::time::Instant::now::h191947beee8509bf]@[wasm code]
<?>.wasm-function[tokio::time::instant::variant::now::h3c864f6578f780bc]@[wasm code]
<?>.wasm-function[tokio::time::instant::Instant::now::haaab15ba5b70db5b]@[wasm code]
<?>.wasm-function[tokio::time::driver::sleep::sleep::ha840de8dc1dc85fb]@[wasm code]
<?>.wasm-function[<backoff::future::TokioSleeper as backoff::future::Sleeper>::sleep::hd6eb274f5257e1c5]@[wasm code]
<?>.wasm-function[<backoff::future::Retry<S,B,N,Fn,Fut> as core::future::future::Future>::poll::h5307a8e7cbba1773]@[wasm code]
When the backoff crate has the wasm-bindgen feature enabled, it would be ideal if it leaned on another form of sleeping, such as using gloo-timer, or if there was a way to choose the time that is used. I note that this crate already uses instant instead of stdInstant, so something like this would be aligned with that.
The text was updated successfully, but these errors were encountered:
264 | type Sleep = ::gloo_timers::future::TimeoutFuture;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn FnMut() + 'static)` cannot be sent between threads safely
@leighmcculloch would you be able to share a working example? I am currently stuck here.
The
backoff::future::retry
works well onwasm32-unknown-unknown
withtokio
as long as there is never an error that triggers the backoff. Once a backoff is triggered theTokioSleeper
is used and tokio::time is used.backoff/src/future.rs
Lines 218 to 224 in 587e2da
The problem with this is that on
wasm32-unknown-unknown
with no time source, a panic is caused by this attempt to sleep with tokio. This is because tokio only uses thestd
time which isn't implemented. The following panic will be seen:When the
backoff
crate has thewasm-bindgen
feature enabled, it would be ideal if it leaned on another form of sleeping, such as using gloo-timer, or if there was a way to choose the time that is used. I note that this crate already usesinstant
instead ofstd
Instant
, so something like this would be aligned with that.The text was updated successfully, but these errors were encountered: