summaryrefslogtreecommitdiff
path: root/ext/websocket
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-04-21 12:25:02 +0530
committerGitHub <noreply@github.com>2023-04-21 08:55:02 +0200
commit4e944dea1d6ad6cc819cbef278b59923eeaa2287 (patch)
tree58a517e585478581ff2a4af99b8f203f4d876907 /ext/websocket
parent1976504c632c78aaadbf24dc94e8ce5626bce9f1 (diff)
fix(ext/websocket): upgrade fastwebsockets to 0.2.4 (#18791)
Fixes https://github.com/denoland/deno/issues/18775
Diffstat (limited to 'ext/websocket')
-rw-r--r--ext/websocket/Cargo.toml2
-rw-r--r--ext/websocket/lib.rs18
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);
+ }
+}