-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry mechanism broken on WASM #1683
Comments
I think it is also related to bitcoindevkit/rust-esplora-client#102 |
@darioAnongba Is it possible to test syncing in |
yes I will test it ASAP and let you know |
I'm not sure if it might be useful, but you can take a look at a partial implementation/usage of |
Thanks @oleonardolima and @ValuedMammal but sorry I tried my best but couldn't implement a Sleeper that would work...
I wasn't able to implement a Sleeper that is Send + Sync The simple Sleeper is: #[derive(Debug, Clone)]
struct GlooTimersSleeper;
impl Sleeper for GlooTimersSleeper {
type Sleep = TimeoutFuture;
fn sleep(dur: Duration) -> Self::Sleep {
sleep(dur)
}
} I tried using something JSFuture instead of gloo_timers, wrapping Sleep in Pin and also using |
Hm yes I see that |
I find it strange that passing your own |
One option could be to use javascript bindings, see |
Guys I managed to make it work. Tried with 100 stop gap full sync on testnet Blockstream and got a lot of 429 that triggered the timer many times. Here is the code: #[derive(Clone)]
pub struct BrowserSleeper;
impl Sleeper for BrowserSleeper {
type Sleep = SendSyncWrapper<TimeoutFuture>;
fn sleep(dur: Duration) -> Self::Sleep {
SendSyncWrapper(sleep(dur))
}
} and the wrapper (let me know your opinion on it): // Wrap a future that is not `Send` or `Sync` and make it `Send` and `Sync`
pub struct SendSyncWrapper<F>(pub F);
unsafe impl<F> Send for SendSyncWrapper<F> {}
unsafe impl<F> Sync for SendSyncWrapper<F> {}
impl<F> Future for SendSyncWrapper<F>
where
F: Future,
{
type Output = F::Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// SAFETY: Since we're in a single-threaded WASM environment, this is safe.
unsafe {
let this = self.get_unchecked_mut();
Pin::new_unchecked(&mut this.0).poll(cx)
}
}
} What are your plans to integrate the latest version of |
Yes we're going to have a 1.0.0-beta.6 which should be the final release candidate for the final 1.0 and it will include an updated version of the |
Describe the bug
The retry mechanism
get_with_retry
does not work on the browser (wasm32-unknown-unknown
) and fails with the following error:The reason is that WebAssembly in browsers doesn’t have direct support for timing mechanisms like
std::time::Instant
orstd::thread::sleep
.To Reproduce
Can run the tests on this repo for
sync
: https://github.com/darioAnongba/bdk-wasmExpected behavior
Build environment
Additional context
Using
gloo-timers
instead ?or 2 functions
The text was updated successfully, but these errors were encountered: