swc-project/swc · error
failed to handle with unknown panic message
Error message
failed to handle with unknown panic message
What it means
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.
Source
Thrown at bindings/binding_html_wasm/src/util.rs:31
skip_filename: false,
..Default::default()
},
|handler| {
//
let result =
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| op(&cm, handler)));
let p = match result {
Ok(v) => return v,
Err(v) => v,
};
if let Some(s) = p.downcast_ref::<String>() {
Err(anyhow!("failed to handle: {s}"))
} else if let Some(s) = p.downcast_ref::<&str>() {
Err(anyhow!("failed to handle: {s}"))
} else {
Err(anyhow!("failed to handle with unknown panic message"))
}
},
)
.map_err(|e| e.to_pretty_error())
}
View on GitHub (pinned to d7d7434666)
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
Defensive patterns
Strategy: try-catch
Try / catch
try {
const out = minify(html, opts);
} catch (e) {
if (String(e).includes('unknown panic message')) {
// no cause available: quarantine input and bisect offline
quarantine(html);
return html;
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Blind debugging in browser environments; typically pairs with edge-case markup or a regression in the vendored compiler version.
Related errors
- failed to handle with unknown panic message
- failed to handle: {s}
- failed to handle: {s}
- failed to handle with unknown panic message
- failed to handle: {s}
AI-assisted analysis of swc-project/swc@d7d7434666 (2026-08-16).
Data as JSON: /api/errors/8e84509f42350e38.
Report an issue: GitHub.