{"record":{"id":"69f6614d9c8a0017","repo":"swc-project/swc","slug":"failed-to-handle-with-unknown-panic-message-69f661","errorCode":null,"errorMessage":"failed to handle with unknown panic message","messagePattern":"failed to handle with unknown panic message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bindings/binding_html_node/src/util.rs","lineNumber":31,"sourceCode":"            skip_filename: false,\n            ..Default::default()\n        },\n        |handler| {\n            //\n            let result =\n                std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| op(&cm, 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    .map_err(|e| e.to_pretty_error())\n}\n","sourceCodeStart":13,"sourceCodeEnd":37,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/bindings/binding_html_node/src/util.rs#L13-L37","documentation":"The fallback arm of the HTML binding's panic bridge: the panic payload inside the @swc/html native operation was neither String nor &str, so no readable text could be extracted and the error surfaces as 'failed to handle with unknown panic message'. It still means a Rust panic occurred and was contained before crashing Node, but the payload type carried no message.","triggerScenarios":"A panic with a structured/unit payload (panic!(()), non-string types, custom panic hooks) inside the HTML transform invoked from @swc/html.","commonSituations":"Memory/allocator-level aborts, poisoned locks, or native plugins with non-string panics; debugging is harder because the message carries no root cause, so environment-level tracing is required.","solutions":["Rerun with RUST_BACKTRACE=1 to capture where the panic originated before the bridge converts it","Minimize the HTML input (bisect the document) to isolate the trigger and report upstream with the repro","Disable suspicious minify options one by one to find the pass that panics","Verify the panic is not caused by a custom panic::set_hook in the embedding process"],"exampleFix":"// before\nconst r = minify(html, opts); // 'unknown panic message'\n\n// after: diagnose with backtraces enabled\n// RUST_BACKTRACE=1 node build.js\ntry {\n  const r = minify(html, opts);\n} catch (e) {\n  // e.message === 'failed to handle with unknown panic message'\n  bisectAndReport(html, opts);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const out = minify(html, opts);\n} catch (e) {\n  if (e.message === 'failed to handle with unknown panic message') {\n    // degrade gracefully: emit unminified HTML and log for later diagnosis\n    return html;\n  }\n  throw e;\n}","preventionTips":["Keep a fallback path (skip minification) for the affected document so one bad page cannot block deploys","Reproduce opaque panics with RUST_BACKTRACE=1 to capture origin","Bisect the document to a minimal failing fragment before reporting upstream"],"tags":["panic","html-binding","node-binding","swc-html","unknown-payload"],"backgroundTag":"caught-panic-as-error","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}