Skip to content

LogPlugin silently overwrites the panic hook in WASM #12546

Closed
@simbleau

Description

@simbleau

The LogPlugin silently overwrites the panic handler on WASM. This means if you attempt to set your own panic handler, or use something like https://github.com/vectorgameexperts/web_panic_report, you have to overwrite it on Startup (thus, your panic handler can't be added until Startup)

Problematic code:

#[cfg(target_arch = "wasm32")]
{
console_error_panic_hook::set_once();
finished_subscriber = subscriber.with(tracing_wasm::WASMLayer::new(
tracing_wasm::WASMLayerConfig::default(),
));
}

This should not be considered acceptable default behavior.

3 options here, open to discussion.

  • (1) Provide a hook to the LogPlugin
  • (2) Take it out (my preferred answer - Logging really has nothing to do with panicking.)
  • (3) Consume the previous hook and wrap it, e.g.
    let old_handler = panic::take_hook();
    panic::set_hook(Box::new(move |infos| {
    eprintln!("{}", tracing_error::SpanTrace::capture());
    old_handler(infos);
    }));

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-DiagnosticsLogging, crash handling, error reporting and performance analysisC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions