{"record":{"id":"15a3eb0d79a92584","repo":"swc-project/swc","slug":"failed-to-handle-with-unknown-panic-message-15a3eb","errorCode":null,"errorMessage":"failed to handle with unknown panic message","messagePattern":"failed to handle with unknown panic message","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"bindings/binding_minifier_node/src/util.rs","lineNumber":52,"sourceCode":"                swc_error_reporters::handler::HandlerOpts {\n                    skip_filename,\n                    ..Default::default()\n                },\n                |handler| {\n                    //\n                    let result = catch_unwind(AssertUnwindSafe(|| op(handler)));\n\n                    let p = match result {\n                        Ok(v) => return v,\n                        Err(v) => v,\n                    };\n\n                    if let Some(s) = p.downcast_ref::<String>() {\n                        Err(anyhow!(\"failed to handle: {s}\"))\n                    } else if let Some(s) = p.downcast_ref::<&str>() {\n                        Err(anyhow!(\"failed to handle: {s}\"))\n                    } else {\n                        Err(anyhow!(\"failed to handle with unknown panic message\"))\n                    }\n                },\n            )\n        })\n        .map_err(|e| e.to_pretty_error())\n}\n\n// This was originally under swc_nodejs_common, but this is not a public\n// interface for the custom binary - they should choose own trace initialization\n// instead. Will keep as hidden for now until there's proper usecase.\n\n/// Deprecated no-op kept for compatibility with existing binding entrypoints.\npub fn init_default_trace_subscriber() {}\n","sourceCodeStart":34,"sourceCodeEnd":66,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/bindings/binding_minifier_node/src/util.rs#L34-L66","documentation":"The minifier napi binding's catch_unwind could not downcast the panic payload to String or &str, so it returns 'failed to handle with unknown panic message'. The panic came from an unwrap()/expect() on a typed error; its Debug payload is discarded, so the message carries no cause - only the pretty handler output around it may help.","triggerScenarios":"Internal .unwrap()/.expect() failures in the JS compressor/mangler triggered by specific inputs through @swc/minifier; payload is the error's Debug value (e.g. a Box<Error> or struct), not a string.","commonSituations":"Blind failures in build pipelines; most common right after version changes when an internal invariant regressed.","solutions":["Re-run the failing input with the swc CLI or a Rust harness with RUST_BACKTRACE=1 to recover the real panic and location","Bisect the JS input and the minify options without a message to guide you","Pin a known-good @swc/minifier version while reporting the case upstream","Include options + input in the upstream issue; unknown-payload panics always warrant a fix"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const out = minify(code, opts);\n} catch (e) {\n  if (String(e).includes('unknown panic message')) {\n    saveRepro(code, opts, null); // no payload info\n    return { code }; // ship unminified rather than fail the release\n  }\n  throw e;\n}","preventionTips":["For unknown-payload panics, first reproduce with RUST_BACKTRACE=1 via the swc CLI to get a stack","Bisect options first (compress/mangle off), then bisect the code - no message will help you"],"tags":["napi","minifier","panic","catch-unwind","unknown-payload"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}