Panic stops the app when using FuturesUnordered

Hello everyone, this topic is related to this one Tokio: number of concurrent tasks - #2 by alice

When a task paniked the application stops working, is there a way, when a panic happens to keep the other tasks running without exit the whole application? (like tokio::spawn)

You can use FutureExt::catch_unwind to create a future that converts panics inside into a result. You can either use it on the future before inserting it, or on the future returned by next() like this:

let res = futs.next().catch_unwind().await;
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.