TLDR Tech / Practical
Tokio select! may cause data loss with certain async operations
When utilizing Rust's Tokio asynchronous runtime, developers should be aware that specific operations like read_exact, read_line, and mpsc::Sender::send are not safe from cancellation within tokio::select! constructs. If these operations are abandoned because another select! branch finishes first, it could lead to lost data, inconsistent protocols, or messages being dropped without notice. The article details these issues with examples and suggests safer approaches, including the use of FramedRead or securing a send permit beforehand.
Read the full story