Common Mistakes with Rust Async
Blog post from Qovery
The text discusses the complexities and common pitfalls associated with asynchronous programming in Rust, focusing on issues such as task cancellation, the misuse of mutex types, and the challenges of future progress starvation. It highlights how tasks can be unexpectedly canceled or stopped, leading to complications like incomplete task counters and the inefficient recreation of futures in loops, which can be mitigated by using constructs like `scopeguard` and `fuse`. The document also warns against holding resources across `await` points, which can cause deadlocks, and suggests early dropping of such resources to prevent them. Furthermore, it critiques the overuse of async programming when traditional synchronous methods could suffice, stressing the increased complexity and debugging difficulties that async introduces. The text concludes by advocating for a balanced approach to async use, treating it as a library rather than the core architecture, to maintain code simplicity and improve team adaptability.