Skip to content

Commit d3d05f8

Browse files
authored
fix(supabase): avoid edge runtime warnings in next.js (#1998)
1 parent 9bfac7f commit d3d05f8

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

packages/core/realtime-js/src/lib/websocket-factory.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ export class WebSocketFactory {
9292
}
9393
}
9494

95-
if (typeof process !== 'undefined') {
96-
// Use dynamic property access to avoid Next.js Edge Runtime static analysis warnings
97-
const processVersions = (process as any)['versions']
95+
// Use dynamic property access to avoid Next.js Edge Runtime static analysis warnings
96+
const _process = (globalThis as any)['process']
97+
if (_process) {
98+
const processVersions = _process['versions']
9899
if (processVersions && processVersions['node']) {
99100
// Remove 'v' prefix if present and parse the major version
100101
const versionString = processVersions['node']

packages/core/supabase-js/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,13 @@ function shouldShowDeprecationWarning(): boolean {
7272
}
7373

7474
// Skip if process is not available (e.g., Edge Runtime)
75-
if (typeof process === 'undefined') {
75+
// Use dynamic property access to avoid Next.js Edge Runtime static analysis warnings
76+
const _process = (globalThis as any)['process']
77+
if (!_process) {
7678
return false
7779
}
7880

79-
// Use dynamic property access to avoid Next.js Edge Runtime static analysis warnings
80-
const processVersion = (process as any)['version']
81+
const processVersion = _process['version']
8182
if (processVersion === undefined || processVersion === null) {
8283
return false
8384
}

0 commit comments

Comments
 (0)