Skip to content

Commit 046c0c2

Browse files
authored
fix(nextjs): Add tracing extension methods in wrapServerComponentWithSentry (#7567)
Our E2E tests were [failing](https://github.com/getsentry/sentry-javascript/actions/runs/4488942749/jobs/7894376591#step:6:6185) because apparently we don't initialize a client while building a NextJS app. This caused the tracing extension methods to not be added, resulting in `startTransaction` returning `undefined`. Not sure if this is the best way to fix this but it seems to work (h/t @timfish for the fix).
1 parent 714a9eb commit 046c0c2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/nextjs/src/server/wrapServerComponentWithSentry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { captureException, getCurrentHub, startTransaction } from '@sentry/core';
1+
import { addTracingExtensions, captureException, getCurrentHub, startTransaction } from '@sentry/core';
22
import { baggageHeaderToDynamicSamplingContext, extractTraceparentData } from '@sentry/utils';
33
import * as domain from 'domain';
44

@@ -11,6 +11,8 @@ export function wrapServerComponentWithSentry<F extends (...args: any[]) => any>
1111
appDirComponent: F,
1212
context: ServerComponentContext,
1313
): F {
14+
addTracingExtensions();
15+
1416
const { componentRoute, componentType } = context;
1517

1618
// Even though users may define server components as async functions, for the client bundles

0 commit comments

Comments
 (0)