Feature/mixfetch disconnect (#3890)
* js error message * Ability to explicitly disconnect mixfetch * removed unused import * added disconnect method directly to sdk package * simplifying error throw Co-authored-by: Mark Sinclair <14054343+mmsinclair@users.noreply.github.com> * added onunload event listener handler * Using global instance of mixfetch to disconnect Co-authored-by: Mark Sinclair <14054343+mmsinclair@users.noreply.github.com> * Bump RC versions * MixFetch, move unload handler to creation and check for undefined `window` * Bump RC version * Force TLS on mixFetch demo * Add info about working around mixed content errors for mixFetch --------- Co-authored-by: Mark Sinclair <14054343+mmsinclair@users.noreply.github.com> Co-authored-by: Mark Sinclair <mmsinclair@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
3ccec3857e
commit
eccd6e16e2
+11
-17
@@ -6,14 +6,17 @@ use log::{log, Level};
|
||||
use std::future::Future;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::{error::Error, time::Duration};
|
||||
use tokio::{
|
||||
sync::{
|
||||
mpsc,
|
||||
watch::{self, error::SendError},
|
||||
},
|
||||
time::sleep,
|
||||
use tokio::sync::{
|
||||
mpsc,
|
||||
watch::{self, error::SendError},
|
||||
};
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
use tokio::time::{sleep, timeout};
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use wasmtimer::tokio::{sleep, timeout};
|
||||
|
||||
const DEFAULT_SHUTDOWN_TIMER_SECS: u64 = 5;
|
||||
|
||||
pub(crate) type SentError = Box<dyn Error + Send + Sync>;
|
||||
@@ -216,16 +219,10 @@ impl TaskManager {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let interrupt_future = tokio::signal::ctrl_c();
|
||||
|
||||
// in wasm we'll never get our shutdown anyway...
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let interrupt_future = futures::future::pending::<()>();
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let wait_future = tokio::time::sleep(Duration::from_secs(self.shutdown_timer_secs));
|
||||
|
||||
// TODO: we should be using a `Delay` here for wasm
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
let wait_future = futures::future::pending::<()>();
|
||||
let wait_future = sleep(Duration::from_secs(self.shutdown_timer_secs));
|
||||
|
||||
tokio::select! {
|
||||
_ = self.notify_tx.closed() => {
|
||||
@@ -300,7 +297,6 @@ impl TaskClient {
|
||||
const MAX_NAME_LENGTH: usize = 128;
|
||||
const OVERFLOW_NAME: &'static str = "reached maximum TaskClient children name depth";
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
const SHUTDOWN_TIMEOUT_WAITING_FOR_SIGNAL_ON_EXIT: Duration = Duration::from_secs(5);
|
||||
|
||||
fn new(
|
||||
@@ -428,12 +424,10 @@ impl TaskClient {
|
||||
|
||||
pub async fn recv_timeout(&mut self) {
|
||||
if self.mode.is_dummy() {
|
||||
#[cfg_attr(target_arch = "wasm32", allow(clippy::needless_return))]
|
||||
return pending().await;
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if let Err(timeout) = tokio::time::timeout(
|
||||
if let Err(timeout) = timeout(
|
||||
Self::SHUTDOWN_TIMEOUT_WAITING_FOR_SIGNAL_ON_EXIT,
|
||||
self.recv(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user