Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolas Haimerl committed Feb 6, 2024
1 parent 9fd1308 commit 0a6c5b6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ic-agent/src/agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,25 @@ impl Agent {
match retry_policy.next_backoff() {
#[cfg(not(target_family = "wasm"))]
Some(duration) => tokio::time::sleep(duration).await,

#[cfg(all(target_family = "wasm", feature = "wasm-bindgen"))]
Some(duration) => {
wasm_bindgen_futures::JsFuture::from(js_sys::Promise::new(&mut |rs, rj| {
if let Err(e) = web_sys::window()
.expect("global window unavailable")
.set_timeout_with_callback_and_timeout_and_arguments_0(
&rs,
duration.as_millis() as _,
)
{
use wasm_bindgen::UnwrapThrowExt;
rj.call1(&rj, &e).unwrap_throw();
}
}))
.await
.expect("unable to setTimeout");
}

None => return Err(AgentError::TimeoutWaitingForResponse()),
}
}
Expand Down

0 comments on commit 0a6c5b6

Please sign in to comment.