From 4e944dea1d6ad6cc819cbef278b59923eeaa2287 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Fri, 21 Apr 2023 12:25:02 +0530 Subject: fix(ext/websocket): upgrade fastwebsockets to 0.2.4 (#18791) Fixes https://github.com/denoland/deno/issues/18775 --- ext/websocket/lib.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'ext/websocket/lib.rs') 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, Response) = 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::() .map(|_| "DOMExceptionNetworkError") } + +// Needed so hyper can use non Send futures +#[derive(Clone)] +struct LocalExecutor; + +impl hyper::rt::Executor for LocalExecutor +where + Fut: Future + 'static, + Fut::Output: 'static, +{ + fn execute(&self, fut: Fut) { + tokio::task::spawn_local(fut); + } +} -- cgit v1.2.3