supabase/supabase-js

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

Closed this issue · 16 comments

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.

Hey @mandarini ! Thanks for your great work so far! I'm still getting this same error in both 2.56.0 and 2.56.1 :)

I'm also getting this error even in 2.57.0, only happens on initial build with fresh .next folder and don't think it actually affects anything

./node_modules/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
A Node.js API is used (process.versions at line: 34) 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/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
./node_modules/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/index.js
./node_modules/.pnpm/@supabase+supabase-js@2.57.0/node_modules/@supabase/supabase-js/dist/module/index.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/createBrowserClient.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/index.js
./src/lib/supabase/middleware.ts

./node_modules/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
A Node.js API is used (process.versions at line: 35) 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/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
./node_modules/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/index.js
./node_modules/.pnpm/@supabase+supabase-js@2.57.0/node_modules/@supabase/supabase-js/dist/module/index.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/createBrowserClient.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/index.js
./src/lib/supabase/middleware.ts

./node_modules/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
A Node.js API is used (process.versions at line: 36) 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/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
./node_modules/.pnpm/@supabase+realtime-js@2.15.4/node_modules/@supabase/realtime-js/dist/module/index.js
./node_modules/.pnpm/@supabase+supabase-js@2.57.0/node_modules/@supabase/supabase-js/dist/module/index.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/createBrowserClient.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/index.js
./src/lib/supabase/middleware.ts

./node_modules/.pnpm/@supabase+supabase-js@2.57.0/node_modules/@supabase/supabase-js/dist/module/index.js
A Node.js API is used (process.version at line: 24) 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/.pnpm/@supabase+supabase-js@2.57.0/node_modules/@supabase/supabase-js/dist/module/index.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/createBrowserClient.js
./node_modules/.pnpm/@supabase+ssr@0.7.0_@supabase+supabase-js@2.57.0/node_modules/@supabase/ssr/dist/module/index.js
./src/lib/supabase/middleware.ts

New version up, 2.57.1. It should fix this issue.

Still happening on latest (2.57.2) on a fresh build without a .next.

Only difference I see is that the process.versions is now erroring out at line 35.

./node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
A Node.js API is used (process.versions at line: 35) 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/realtime-js/dist/module/lib/websocket-factory.js
./node_modules/@supabase/realtime-js/dist/module/index.js
./node_modules/@supabase/supabase-js/dist/module/index.js
./node_modules/@supabase/ssr/dist/module/createBrowserClient.js
./node_modules/@supabase/ssr/dist/module/index.js
./src/lib/supabase/middleware.ts

./node_modules/@supabase/supabase-js/dist/module/index.js
A Node.js API is used (process.version at line: 24) 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
./node_modules/@supabase/ssr/dist/module/createBrowserClient.js
./node_modules/@supabase/ssr/dist/module/index.js
./src/lib/supabase/middleware.ts

same here after 2.57.2 and without .next

Ok. Is this breaking your app, or is it mostly a warning? If it's not breaking your app, I will pause investigating for the time being, because there's some refactoring coming up, which will probably fix this in its root.

Nah just a warning, nothing actually seems to be breaking so far.

Thanks, good to know. Yes, from what I've seen it's "just" a warning, too, so let's defer from any more fixes atm, until we have a more solid refactor in the near future. Thank you all!

Sounds good, maybe we should have this issue open in case anybody else sees the error log.

Reopening for now because warning is still there.

Still up on "@supabase/ssr": "^0.3.0", "@supabase/supabase-js": "^2.76.0", , on the latest nextjs "next": "^15.5.6":

./node_modules/@supabase/realtime-js/dist/module/lib/websocket-factory.js
A Node.js API is used (process.versions at line: 32) 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/realtime-js/dist/module/lib/websocket-factory.js
./node_modules/@supabase/realtime-js/dist/module/index.js
./node_modules/@supabase/supabase-js/dist/module/index.js
./node_modules/@supabase/ssr/dist/index.mjs
./supabase/middleware.ts

./node_modules/@supabase/supabase-js/dist/module/index.js
A Node.js API is used (process.version at line: 24) 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
./node_modules/@supabase/ssr/dist/index.mjs
./supabase/middleware.ts

also #1552 seems a duplicate to this one.

Hey thanks for reporting it. Just in case, can you update to ^2.76.1, because 2.76.0 introduced a bug (unrelated to this issue, but just for sanity purposes).

Someone was able to find a fix to this?

Is this still happening? We dropped support for Node 18 and did some other improvements as well. Can you please let me know? @dealmengor @cristigoia @thisislvca

Hey! Nop, not seeing it anymore. I did upgrade to next 16 though, which uses node for the middleware too, meaning the original issue shouldn't pop up anyways :)

Thanks for following up! Closing as resolved!