Is it safe to end a program raised a fatal error by panic in an async context?

I just observed that tasks spawned by tokio::spawn do not stop the entire program when it panics internally. If the program raise a critical enough error that the entire program is expected to stop, what is the best practice?

If you return from main, then the program should exit. You can also call std::process::abort, but this will not call any destructors or any other kind of cleanup.

There's also the (unstable-ish) Builder::unhandled_panic() so hopefully this will be simpler sometime soon.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.