snapview / tokio-tungstenite

Future-based Tungstenite for Tokio. Lightweight stream-based WebSocket implementation
MIT License
1.88k stars 236 forks source link

Is `Sink::send` cancellation safe? #344

Closed feelingnothing closed 3 months ago

feelingnothing commented 3 months ago

I'm an amateur is cancellation safety, but as far as I can see there is no state handling (expect ready, which I don't think can cause problems) in polling. Basically everything in relation to serializing is handled by tungstenite in one poll. Am I correct?

daniel-abramov commented 3 months ago

I'm not sure what you mean by "safe," but not polling a future returned by send() after calling it neither causes a panic nor breaks the internal logic of tungstenite. Consequently, not polling the future means that no progress is made, and there is no guarantee that the message has been sent.