Skip to content

Commit dd0e8eb

Browse files
committed
fix(nextjs): replace unsupported process.turbopack with process.env.TURBOPACK for Edge Runtime
1 parent 3332576 commit dd0e8eb

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

packages/nextjs/src/client/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getDefaultIntegrations as getReactDefaultIntegrations, init as reactIni
55
import { devErrorSymbolicationEventProcessor } from '../common/devErrorSymbolicationEventProcessor';
66
import { getVercelEnv } from '../common/getVercelEnv';
77
import { isRedirectNavigationError } from '../common/nextNavigationErrorUtils';
8+
import { isTurbopack } from '../common/utils/isTurbopack';
89
import { browserTracingIntegration } from './browserTracingIntegration';
910
import { nextjsClientStackFrameNormalizationIntegration } from './clientNormalizationIntegration';
1011
import { INCOMPLETE_APP_ROUTER_INSTRUMENTATION_TRANSACTION_NAME } from './routing/appRouterRoutingInstrumentation';
@@ -77,7 +78,7 @@ export function init(options: BrowserOptions): Client | undefined {
7778
}
7879

7980
try {
80-
if (process.env.TURBOPACK === '1') {
81+
if (isTurbopack) {
8182
getGlobalScope().setTag('turbopack', true);
8283
}
8384
} catch {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const isTurbopack = process.env.TURBOPACK === '1' || (typeof process !== 'undefined' && 'turbopack' in process && process.turbopack);

packages/nextjs/src/edge/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
import type { VercelEdgeOptions } from '@sentry/vercel-edge';
1515
import { getDefaultIntegrations, init as vercelEdgeInit } from '@sentry/vercel-edge';
1616
import { isBuild } from '../common/utils/isBuild';
17+
import { isTurbopack } from '../common/utils/isTurbopack';
1718
import { flushSafelyWithTimeout } from '../common/utils/responseEnd';
1819
import { distDirRewriteFramesIntegration } from './distDirRewriteFramesIntegration';
1920

@@ -95,7 +96,7 @@ export function init(options: VercelEdgeOptions = {}): void {
9596
});
9697

9798
try {
98-
if (process.env.TURBOPACK === '1') {
99+
if (isTurbopack) {
99100
getGlobalScope().setTag('turbopack', true);
100101
}
101102
} catch {

packages/nextjs/src/server/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
TRANSACTION_ATTR_SHOULD_DROP_TRANSACTION,
3838
} from '../common/span-attributes-with-logic-attached';
3939
import { isBuild } from '../common/utils/isBuild';
40+
import { isTurbopack } from '../common/utils/isTurbopack';
4041
import { distDirRewriteFramesIntegration } from './distDirRewriteFramesIntegration';
4142

4243
export * from '@sentry/node';
@@ -368,7 +369,7 @@ export function init(options: NodeOptions): NodeClient | undefined {
368369
}
369370

370371
try {
371-
if (process.env.TURBOPACK === '1') {
372+
if (isTurbopack) {
372373
getGlobalScope().setTag('turbopack', true);
373374
}
374375
} catch {

0 commit comments

Comments
 (0)