mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
use event.message when no event.error in HMR during event
This commit is contained in:
@@ -615,7 +615,6 @@ const NativeStackFrame = ({
|
||||
<div
|
||||
title={StackFrameScope[scope]}
|
||||
className="BunError-StackFrame-identifier"
|
||||
// @ts-expect-error Custom CSS variables are not known by TypeScript
|
||||
style={{ "--max-length": `${maxLength}ch` }}
|
||||
>
|
||||
{getNativeStackFrameIdentifier(frame)}
|
||||
|
||||
@@ -237,8 +237,18 @@ function onHmrLoadError(event: Event | string, source?: string, lineno?: number,
|
||||
}
|
||||
|
||||
window.addEventListener("error", event => {
|
||||
onRuntimeError(event.error, true, false);
|
||||
// In rare cases the error property might be null
|
||||
// but it's unlikely that both error and message are gone
|
||||
const value = event.error || event.message;
|
||||
if (!value) {
|
||||
console.log(
|
||||
"[Bun] The HMR client detected a runtime error, but no useful value was found. Below is the full error event:",
|
||||
);
|
||||
console.log(event);
|
||||
}
|
||||
onRuntimeError(value, true, false);
|
||||
});
|
||||
|
||||
window.addEventListener("unhandledrejection", event => {
|
||||
onRuntimeError(event.reason, true, true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user