Skip to content

Node.js 18 deprecation warning added in v2.52.1 causes Next.js Edge Runtime build warnings #1515

@masda70

Description

@masda70

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

  1. Create a Next.js project with middleware that imports @supabase/supabase-js (v2.52.1+)
  2. Use the middleware with Supabase client
  3. Run next build
  4. 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:

  1. The code is properly guarded with runtime checks
  2. It will never execute in Edge Runtime (typeof process === 'undefined' returns true)
  3. 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:

  1. Use dynamic property access to avoid static analysis:

    const processVersion = process['version'] // Dynamic access
  2. 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')
    }
  3. 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions