Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vercel NextJS with-supabase example does not work with latest node20 runtime #1255

Closed
2 tasks done
chrisui opened this issue Aug 5, 2024 · 3 comments
Closed
2 tasks done
Labels
bug Something isn't working

Comments

@chrisui
Copy link

chrisui commented Aug 5, 2024

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

Node fetch failure when trying to use auth api.

TypeError: fetch failed
    at node:internal/deps/undici/undici:12502:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ah (/var/task/apps/www/.next/server/chunks/125.js:1:75941)
    at async au (/var/task/apps/www/.next/server/chunks/125.js:1:75685)
    at async aP.signInAnonymously (/var/task/apps/www/.next/server/chunks/125.js:1:86849)
    at async P (/var/task/apps/www/.next/server/app/quiz/hair-type/page.js:1:5165)
    at async /var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:16:418
    at async rP (/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:15:7978)
    at async r5 (/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js:18:1139)
    at async es (/var/task/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/server.runtime.prod.js:16:26320) {
  [cause]: Error: connect ECONNREFUSED 127.0.0.1:54321
      at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1606:16)
      at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    errno: -111,
    code: 'ECONNREFUSED',
    syscall: 'connect',
    address: '127.0.0.1',
    port: 54321
  }
}

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Following the guide to use the next boilerplate and create a project with supabase auth. only change I made was to use supabase.auth.signInAnonymously within a server action.

I deployed to vercel (where default runtime is the latest, node20) and encountered the error. Tore my hair out for a while wondering if I was missing env (particularly because I saw the 127.0.0.1 portion but I think a bit of a red herring in the end) and eventually tried to downgrade the runtime to node18 and redeploy. It worked.

https://vercel.com/templates/next.js/supabase

Expected behavior

No error when using node 20.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [chrome
  • Version of supabase-js: "@supabase/ssr": "^0.4.0", "@supabase/supabase-js": "^2.45.0",
  • Version of Node.js: 20

Additional context

The vercel template page says to report any issues here.

@chrisui chrisui added the bug Something isn't working label Aug 5, 2024
@encima
Copy link
Member

encima commented Aug 6, 2024

Thanks for opening, can you confirm this is only occurring with node 20 and not node 22?

Also, fetch has changed a bit between 20 and 21 but you can use a custom fetch implementation (see here). Could you test using a different fetch implementation and report back?

@encima encima transferred this issue from supabase/supabase Aug 6, 2024
@chrisui
Copy link
Author

chrisui commented Aug 16, 2024

Hey @encima, unfortunately this can't be confirmed because the issue is encountered when deployed to Vercel which is running on AWS Lambda which only supports node.20x/18x/16x runtimes and not yet 22.

@encima
Copy link
Member

encima commented Aug 16, 2024

Hi @chrisui

No worries, you can use a custom fetch implementation in that case. Let me know if it doesn't work and we can reopen :)

@encima encima closed this as completed Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants