{"record":{"id":"8e84509f42350e38","repo":"swc-project/swc","slug":"failed-to-handle-with-unknown-panic-message-8e8450","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_wasm/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/d7d74346665e36e692aa07e13d4ee3ee692ee35c/bindings/binding_html_wasm/src/util.rs#L13-L37","documentation":"The wasm HTML binding's catch_unwind could not downcast the panic payload to String or &str ('failed to handle with unknown panic message'). The panic originated from unwrap()/expect() on typed errors, so the payload is a non-string value and the real cause is not included in the message.","triggerScenarios":"Internal .unwrap()/.expect() failures in the wasm-compiled swc HTML compiler triggered by specific inputs; the payload is the Debug value of the unwrapped error type.","commonSituations":"Blind debugging in browser environments; typically pairs with edge-case markup or a regression in the vendored compiler version.","solutions":["Reproduce with the swc CLI or napi binding where RUST_BACKTRACE gives the real panic location","Bisect the input to find the trigger without a message","Upgrade the wasm html binding","Report upstream with a repro - non-string panic payloads hidden by this path are bugs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const out = minify(html, opts);\n} catch (e) {\n  if (String(e).includes('unknown panic message')) {\n    // no cause available: quarantine input and bisect offline\n    quarantine(html);\n    return html;\n  }\n  throw e;\n}","preventionTips":["Assume zero diagnostic value from 'unknown panic message': always retain the raw input for offline reproduction","Cross-check quarantined inputs against the napi binding or swc CLI to separate wasm-specific from input-specific failures"],"tags":["wasm","html","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"}