-
-
Notifications
You must be signed in to change notification settings - Fork 423
Description
Bug report
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
The Node.js deprecation warning code introduced in v2.52.1 (commit ede368c) causes Next.js Edge Runtime compatibility warnings during build, even though the code is properly guarded and won't execute in Edge Runtime.
The issue is in /dist/module/index.js
lines 17-21 where process.version
is accessed. Next.js static analysis flags this as incompatible with Edge Runtime, despite the runtime guards that prevent execution.
// This causes Next.js Edge Runtime build warnings
function shouldShowDeprecationWarning() {
if (typeof window !== 'undefined' ||
typeof process === 'undefined' ||
process.version === undefined || // ← Static analysis flags this
process.version === null) {
return false;
}
const versionMatch = process.version.match(/^v(\d+)\./); // ← And this
// ...
}
To Reproduce
- Create a Next.js project with middleware that imports
@supabase/supabase-js
(v2.52.1+) - Use the middleware with Supabase client
- Run
next build
- See Edge Runtime compatibility warnings:
A Node.js API is used (process.version at line: 17) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime
Import trace for requested module:
./node_modules/@supabase/supabase-js/dist/module/index.js
Minimal reproduction:
// middleware.ts
import { createServerClient } from '@supabase/ssr'
import { NextRequest } from 'next/server'
export async function middleware(request: NextRequest) {
const supabase = createServerClient(/* ... */)
// Edge Runtime warnings occur during build
}
Expected behavior
The deprecation warning should not trigger Next.js Edge Runtime compatibility warnings, since:
- The code is properly guarded with runtime checks
- It will never execute in Edge Runtime (
typeof process === 'undefined'
returnstrue
) - The warning is only intended for actual Node.js environments
Screenshots
Build warning output:
A Node.js API is used (process.version at line: 17) which is not supported in the Edge Runtime.
A Node.js API is used (process.version at line: 21) which is not supported in the Edge Runtime.
System information
- OS: Windows/macOS/Linux (affects all platforms)
- Framework: Next.js with Edge Runtime middleware
- Version of supabase-js: 2.52.1, 2.53.0
- Version of Node.js: 20.x+
- Next.js version: 15.x
Additional context
Root cause: The deprecation warning was added in commit ede368c (#1506) but uses static process.version
access that triggers Next.js static analysis warnings.
Suggested solutions:
-
Use dynamic property access to avoid static analysis:
const processVersion = process['version'] // Dynamic access
-
Move to a separate module that's conditionally imported:
// Only import in Node.js environments if (typeof process !== 'undefined' && process.version) { import('./deprecation-warning.js') }
-
Use globalThis approach:
const nodeProcess = globalThis.process if (nodeProcess?.version) { /* ... */ }
This affects any Next.js project using Supabase with middleware, which is a very common use case. The warning serves a good purpose but shouldn't break Edge Runtime compatibility.