Hey all, I'm using Tokio with the #[tokio::main] attribute. When a panic occurs I noticed that the current panicking task will end but the program is still running. I assume that is because other tasks are running. I'm using tokio::spawn to start new async tasks.
I would like the entire program to end as soon as any panic occurs. I plan on having long running programs doing some calculations and I need the process to exit with an error code as soon as possible.
Is there any way of doing this ? Am I missing something here ?
It is completely analogous to how threads spawned with std::thread::spawn also prevent panics from crashing the program.
The most direct way of causing any panic to end the program is to configure them to abort the process instead of unwinding the stack. Otherwise, you will have to somehow propagate them up and terminate the program.