Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a mechanism for contextualizing panics #21973

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cole-miller
Copy link
Contributor

Introduces a way for callsites throughout the Zed client to pass context to our custom panic hook (defined in crates/zed/src/reliability.rs) and ultimately to #panics in the Zed Slack. When we see a particular panic backtrace repeatedly and the cause isn't immediately obvious, this allows us to update the code to package some additional contextual information when that panic occurs in the future. It combines well with catch_unwind for cases where we want to stop the panic from crashing Zed but still get a telemetry report about it, since the panic hook is called even for panics that are caught. Usage:

// Don't catch the panic, just propagate it.
let result = {
    let _guard = reliability::hook_fn({
        let gizmo = gizmo.clone();
        move |_panic_info| format!("gizmo state: {gizmo:?}")
    });
    gizmo.panicky_operation()
}

// Catch the panic but still send a report.
let result: std::thread::Result<T> = reliability::hook_fn(|_| format!("context!")).catch_unwind(|| gizmo.panicky_operation());

// Catch the panic from polling a future.
let result: std::thread::Result<T> = reliability::hook_fn(|_| format!("context!")).catch_unwind_future(gizmo.panicky_async_operation()).await;

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant