diff options
Diffstat (limited to 'ext/websocket')
-rw-r--r-- | ext/websocket/Cargo.toml | 2 | ||||
-rw-r--r-- | ext/websocket/lib.rs | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/ext/websocket/Cargo.toml b/ext/websocket/Cargo.toml index 03cb3076a..a96b6cceb 100644 --- a/ext/websocket/Cargo.toml +++ b/ext/websocket/Cargo.toml @@ -16,7 +16,7 @@ path = "lib.rs" [dependencies] deno_core.workspace = true deno_tls.workspace = true -fastwebsockets = { version = "0.2.1", features = ["upgrade"] } +fastwebsockets = { version = "0.2.4", features = ["upgrade"] } http.workspace = true hyper.workspace = true serde.workspace = true 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); + } +} |