tokio-rs/tokio · error · syn::Error

No such unhandled panic behavior `{s}`. The unhandled panic

Error message

No such unhandled panic behavior `{s}`. The unhandled panic behaviors are `ignore` and `shutdown_runtime`.

What it means

`UnhandledPanic::from_str` (entry.rs:46) only accepts `ignore` and `shutdown_runtime`. Any other value (including typos or wrong case) falls through to this formatted error, listing the two valid behaviors.

Source

Thrown at tokio-macros/src/entry.rs:41

            "basic_scheduler" => Err("The `basic_scheduler` runtime flavor has been renamed to `current_thread`.".to_string()),
            "threaded_scheduler" => Err("The `threaded_scheduler` runtime flavor has been renamed to `multi_thread`.".to_string()),
            _ => Err(format!("No such runtime flavor `{s}`. The runtime flavors are `current_thread`, `local`, and `multi_thread`.")),
        }
    }
}

#[derive(Clone, Copy, PartialEq)]
enum UnhandledPanic {
    Ignore,
    ShutdownRuntime,
}

impl UnhandledPanic {
    fn from_str(s: &str) -> Result<UnhandledPanic, String> {
        match s {
            "ignore" => Ok(UnhandledPanic::Ignore),
            "shutdown_runtime" => Ok(UnhandledPanic::ShutdownRuntime),
            _ => Err(format!("No such unhandled panic behavior `{s}`. The unhandled panic behaviors are `ignore` and `shutdown_runtime`.")),
        }
    }

    fn into_tokens(self, crate_path: &TokenStream) -> TokenStream {
        match self {
            UnhandledPanic::Ignore => quote! { #crate_path::runtime::UnhandledPanic::Ignore },
            UnhandledPanic::ShutdownRuntime => {
                quote! { #crate_path::runtime::UnhandledPanic::ShutdownRuntime }
            }
        }
    }
}

struct FinalConfig {
    name: Option<String>,
    flavor: RuntimeFlavor,
    worker_threads: Option<usize>,
    start_paused: Option<bool>,

View on GitHub (pinned to 625954f365)

Solutions

  1. Use exactly `ignore` or `shutdown_runtime` (lowercase, with the underscore).
  2. If unsure which you need, `ignore` leaves the runtime running; `shutdown_runtime` tears it down on the first task panic.

Example fix

// before
#[tokio::main(flavor = "current_thread", unhandled_panic = "shutdown")]
async fn main() {}

// after
#[tokio::main(flavor = "current_thread", unhandled_panic = "shutdown_runtime")]
async fn main() {}
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Writing `#[tokio::main(unhandled_panic = "kill")]`, `unhandled_panic = "ShutdownRuntime"`, or any unrecognized behavior name.

Common situations: Guessing the behavior name; mixing in terms from other runtimes; case sensitivity.

Related errors


AI-assisted analysis of tokio-rs/tokio@625954f365 (2026-08-11). Data as JSON: /api/errors/aa83f8484df70da9. Report an issue: GitHub.