Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nextjs/src/common/_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export async function captureUnderscoreErrorException(contextOrProps: ContextOrP
scope.addEventProcessor(event => {
addExceptionMechanism(event, {
type: 'instrument',
handled: true,
handled: false,
data: {
function: '_error.getInitialProps',
},
Expand Down
28 changes: 24 additions & 4 deletions packages/nextjs/src/common/utils/wrapperUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
startTransaction,
} from '@sentry/core';
import type { Span, Transaction } from '@sentry/types';
import { isString, tracingContextFromHeaders } from '@sentry/utils';
import { addExceptionMechanism, isString, tracingContextFromHeaders } from '@sentry/utils';
import type { IncomingMessage, ServerResponse } from 'http';

import { platformSupportsStreaming } from './platformSupportsStreaming';
Expand Down Expand Up @@ -46,8 +46,18 @@ export function withErrorInstrumentation<F extends (...args: any[]) => any>(
try {
return await origFunction.apply(this, origFunctionArguments);
} catch (e) {
// TODO: Extract error logic from `withSentry` in here or create a new wrapper with said logic or something like that.
captureException(e);
// TODO: Extract error logic from `withSentry` in here or create a new wrapper with said logic or something like that.#
Comment thread
Lms24 marked this conversation as resolved.
Outdated
captureException(e, scope => {
scope.addEventProcessor(event => {
addExceptionMechanism(event, {
handled: false,
});
return event;
});

return scope;
});

throw e;
}
};
Expand Down Expand Up @@ -217,7 +227,17 @@ export async function callDataFetcherTraced<F extends (...args: any[]) => Promis
span.finish();

// TODO Copy more robust error handling over from `withSentry`
captureException(err);
captureException(err, scope => {
scope.addEventProcessor(event => {
addExceptionMechanism(event, {
handled: false,
});
return event;
});

return scope;
});

throw err;
}
}
2 changes: 1 addition & 1 deletion packages/nextjs/src/common/wrapApiHandlerWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export function withSentry(apiHandler: NextApiHandler, parameterizedRoute?: stri
currentScope.addEventProcessor(event => {
addExceptionMechanism(event, {
type: 'instrument',
handled: true,
handled: false,
data: {
wrapped_handler: wrappingTarget.name,
function: 'withSentry',
Expand Down
14 changes: 12 additions & 2 deletions packages/nextjs/src/common/wrapServerComponentWithSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
runWithAsyncContext,
startTransaction,
} from '@sentry/core';
import { tracingContextFromHeaders } from '@sentry/utils';
import { addExceptionMechanism, tracingContextFromHeaders } from '@sentry/utils';

import { isNotFoundNavigationError, isRedirectNavigationError } from '../common/nextNavigationErrorUtils';
import type { ServerComponentContext } from '../common/types';
Expand Down Expand Up @@ -62,7 +62,17 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>
// We don't want to report redirects
} else {
transaction.setStatus('internal_error');
captureException(e);

captureException(e, scope => {
scope.addEventProcessor(event => {
addExceptionMechanism(event, {
handled: false,
});
return event;
});

return scope;
});
}

transaction.finish();
Expand Down