Skip to content

Commit f26f68c

Browse files
timfishAbhiPrasad
authored andcommitted
fix(nextjs): Client code should not use Node global (#10925)
Found while working through ESM issues in #10833. For whatever reason this passes all the integration tests until ESM is used 🤯
1 parent ef59a91 commit f26f68c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

packages/nextjs/src/client/rewriteFramesIntegration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { defineIntegration } from '@sentry/core';
22
import { rewriteFramesIntegration as originalRewriteFramesIntegration } from '@sentry/integrations';
33
import type { IntegrationFn, StackFrame } from '@sentry/types';
4+
import { GLOBAL_OBJ } from '@sentry/utils';
45

5-
const globalWithInjectedValues = global as typeof global & {
6+
const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
67
__rewriteFramesAssetPrefixPath__: string;
78
};
89

packages/nextjs/src/client/tunnelRoute.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { BrowserOptions } from '@sentry/react';
2-
import { dsnFromString, logger } from '@sentry/utils';
2+
import { GLOBAL_OBJ, dsnFromString, logger } from '@sentry/utils';
33

44
import { DEBUG_BUILD } from '../common/debug-build';
55

6-
const globalWithInjectedValues = global as typeof global & {
6+
const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
77
__sentryRewritesTunnelPath__?: string;
88
};
99

packages/nextjs/src/server/rewriteFramesIntegration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
rewriteFramesIntegration as originalRewriteFramesIntegration,
66
} from '@sentry/integrations';
77
import type { IntegrationFn, StackFrame } from '@sentry/types';
8-
import { escapeStringForRegex } from '@sentry/utils';
8+
import { GLOBAL_OBJ, escapeStringForRegex } from '@sentry/utils';
99

10-
const globalWithInjectedValues = global as typeof global & {
10+
const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
1111
__rewriteFramesDistDir__?: string;
1212
};
1313

0 commit comments

Comments
 (0)