diff --git a/packages/next/src/client/components/react-dev-overlay/internal/helpers/use-error-handler.ts b/packages/next/src/client/components/react-dev-overlay/internal/helpers/use-error-handler.ts index f714602444170..d884fcfb65a97 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/helpers/use-error-handler.ts +++ b/packages/next/src/client/components/react-dev-overlay/internal/helpers/use-error-handler.ts @@ -75,19 +75,14 @@ function onUnhandledRejection(ev: WindowEventMap['unhandledrejection']): void { return } - if ( - !reason || - !(reason instanceof Error) || - typeof reason.stack !== 'string' - ) { + if (!isError(reason)) { // A non-error was thrown, we don't have anything to show. :-( return } - const e = reason - rejectionQueue.push(e) + rejectionQueue.push(reason) for (const handler of rejectionHandlers) { - handler(e) + handler(reason) } } @@ -99,7 +94,6 @@ export function handleGlobalErrors() { } catch {} window.addEventListener('error', onUnhandledError) - window.addEventListener('unhandledrejection', onUnhandledRejection) } }