Problem
Connection is Send throughout the library:
ConnectTo<R: Role>: Send + 'static
fn connect_to(...) -> impl Future<Output = Result<()>> + Send
Role: Debug + Clone + Send + Sync + 'static + Eq + Ord + Hash
- handler futures return
impl Future<...> + Send
SessionBlockState: Send + 'static + Sync
BoxFuture (which is Send) rather than LocalBoxFuture at every boxed-future site
The doc comment on connect_to states it outright: "The future must be Send."
Since the wasm target gating landed, the crate compiles for wasm32-unknown-unknown, but browser runtimes are single-threaded and the surrounding types (web_sys::WebSocket, js_sys handles, Dioxus/Leptos/yew signals, Rc/RefCell) are !Send.
Impact
Adoption is possible but requires wrapping the SDK: handlers forward plain data into a futures::mpsc, and the !Send world drains it on the far side.
It works, but it is a layer added rather than a layer removed, which weakens the case for adopting the SDK over a hand-rolled client in the first place.
Proposal
Conditionally relax the bounds for WASM:
#[cfg(not(target_family = "wasm"))]
pub trait MaybeSend: Send {}
#[cfg(not(target_family = "wasm"))]
impl<T: Send> MaybeSend for T {}
#[cfg(target_family = "wasm")]
pub trait MaybeSend {}
#[cfg(target_family = "wasm")]
impl<T> MaybeSend for T {}
plus a MaybeSendBoxFuture<'a, T> alias.
Problem
Connection is
Sendthroughout the library:ConnectTo<R: Role>: Send + 'staticfn connect_to(...) -> impl Future<Output = Result<()>> + SendRole: Debug + Clone + Send + Sync + 'static + Eq + Ord + Hashimpl Future<...> + SendSessionBlockState: Send + 'static + SyncBoxFuture(which isSend) rather thanLocalBoxFutureat every boxed-future siteThe doc comment on
connect_tostates it outright: "The future must beSend."Since the wasm target gating landed, the crate compiles for
wasm32-unknown-unknown, but browser runtimes are single-threaded and the surrounding types (web_sys::WebSocket,js_syshandles, Dioxus/Leptos/yew signals,Rc/RefCell) are!Send.Impact
Adoption is possible but requires wrapping the SDK: handlers forward plain data into a
futures::mpsc, and the!Sendworld drains it on the far side.It works, but it is a layer added rather than a layer removed, which weakens the case for adopting the SDK over a hand-rolled client in the first place.
Proposal
Conditionally relax the bounds for WASM:
plus a
MaybeSendBoxFuture<'a, T>alias.