diff options
Diffstat (limited to 'ext/websocket/lib.rs')
-rw-r--r-- | ext/websocket/lib.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index f63191a8e..798856bc1 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -34,6 +34,7 @@ use std::cell::Cell; use std::cell::RefCell; use std::convert::TryFrom; use std::fmt; +use std::future::Future; use std::path::PathBuf; use std::rc::Rc; use std::sync::Arc; @@ -239,7 +240,8 @@ where _ => unreachable!(), }; - let client = fastwebsockets::handshake::client(request, socket); + let client = + fastwebsockets::handshake::client(&LocalExecutor, request, socket); let (stream, response): (WebSocket<Upgraded>, Response<Body>) = if let Some(cancel_resource) = cancel_resource { @@ -533,3 +535,17 @@ pub fn get_network_error_class_name(e: &AnyError) -> Option<&'static str> { e.downcast_ref::<DomExceptionNetworkError>() .map(|_| "DOMExceptionNetworkError") } + +// Needed so hyper can use non Send futures +#[derive(Clone)] +struct LocalExecutor; + +impl<Fut> hyper::rt::Executor<Fut> for LocalExecutor +where + Fut: Future + 'static, + Fut::Output: 'static, +{ + fn execute(&self, fut: Fut) { + tokio::task::spawn_local(fut); + } +} |