diff --git a/packages/nextjs/src/index.server.ts b/packages/nextjs/src/index.server.ts index 285c6eb1599e..a61e49fe758f 100644 --- a/packages/nextjs/src/index.server.ts +++ b/packages/nextjs/src/index.server.ts @@ -118,6 +118,11 @@ function addServerIntegrations(options: NextjsOptions): void { }); integrations = addOrUpdateIntegration(defaultRewriteFramesIntegration, integrations); + const nativeBehaviourOnUncaughtException = new Integrations.OnUncaughtException(); + integrations = addOrUpdateIntegration(nativeBehaviourOnUncaughtException, integrations, { + _options: { exitEvenIfOtherHandlersAreRegistered: false }, + }); + if (hasTracingEnabled(options)) { const defaultHttpTracingIntegration = new Integrations.Http({ tracing: true }); integrations = addOrUpdateIntegration(defaultHttpTracingIntegration, integrations, { diff --git a/packages/node/src/integrations/onuncaughtexception.ts b/packages/node/src/integrations/onuncaughtexception.ts index 722fdc2b1cf4..2108e2829f63 100644 --- a/packages/node/src/integrations/onuncaughtexception.ts +++ b/packages/node/src/integrations/onuncaughtexception.ts @@ -7,6 +7,7 @@ import { logAndExitProcess } from './utils/errorhandling'; type OnFatalErrorHandler = (firstError: Error, secondError?: Error) => void; +// CAREFUL: Please think twice before updating the way _options looks because the Next.js SDK depends on it in `index.server.ts` interface OnUncaughtExceptionOptions { // TODO(v8): Evaluate whether we should switch the default behaviour here. // Also, we can evaluate using https://nodejs.org/api/process.html#event-uncaughtexceptionmonitor per default, and @@ -48,6 +49,7 @@ export class OnUncaughtException implements Integration { */ public readonly handler: (error: Error) => void = this._makeErrorHandler(); + // CAREFUL: Please think twice before updating the way _options looks because the Next.js SDK depends on it in `index.server.ts` private readonly _options: OnUncaughtExceptionOptions; /**