supabase icon indicating copy to clipboard operation
supabase copied to clipboard

Can't deploy to Vercel Edge Functions to work if supabase module is present

Open Zebnastien opened this issue 2 years ago • 9 comments

Version

"@nuxtjs/supabase": "^0.3.1", "nuxt": "^3.2.2"

Steps to reproduce

  • Start a new Nuxt 3 project.
  • Install supabase module and add it to nuxt.config.ts modules array.
  • In nuxt.config.ts, set nitro preset: nitro: { preset: "vercel-edge", },
  • Setup .env variables in Vercel.
  • Deploy to Vercel.

What is Expected?

When nitro preset is default node-js, everythings goes right. With Vercel-edge preset, the same should happen.

What is actually happening?

It builds but here is the result when you try to browse it:

image

And here is the log:

image

Zebnastien avatar Feb 18 '23 13:02 Zebnastien

#120

MarianMichalovic avatar Feb 22 '23 14:02 MarianMichalovic

Thanks man !

Zebnastien avatar Feb 25 '23 17:02 Zebnastien

This is still an issue for me. I can make it work if I switch to Vercel serverless function but it breaks on their edge functions.

Pwntus avatar Mar 16 '23 09:03 Pwntus

I think this is come from a proxy probleme with /api/_supabase/..., vercel use '/api' for edge function

marc-tech avatar Mar 26 '23 23:03 marc-tech

"nuxt": "^3.4.1", "@nuxtjs/supabase": "^0.3.5"

Deployed a project to Vercel with the edge present i got the following error:

TypeError: Cannot read properties of undefined (reading 'bind')
    at (index.mjs:1:493518)
    at (__nitro:middleware.js:1:17)

If i remove the @nuxtjs/supabase module everything is working fine.

maximilian-schwarz avatar Apr 27 '23 09:04 maximilian-schwarz

Sorry to add to the echoes, but I'm getting this same thing. Has anyone figured this out?

If anyone can take a crack at it, here's Vercel's default Nuxt starter for easier deploy: https://vercel.com/templates/nuxt/nuxtjs-boilerplate

So long as this module is included in the nuxt-config, deploy fails

chasebank avatar May 10 '23 03:05 chasebank

Hello, I still have the problem. Is there a solution?

JuBertoo avatar Jul 04 '23 11:07 JuBertoo

"nuxt": "^3.4.1", "@nuxtjs/supabase": "^0.3.5"

Deployed a project to Vercel with the edge present i got the following error:

TypeError: Cannot read properties of undefined (reading 'bind')
    at (index.mjs:1:493518)
    at (__nitro:middleware.js:1:17)

If i remove the @nuxtjs/supabase module everything is working fine.

I fixed this error by patching the dependency websocket used by Supabase Realtime. (I used the patch-package lib)

diff --git a/node_modules/websocket/lib/WebSocketConnection.js b/node_modules/websocket/lib/WebSocketConnection.js
index 219de63..ed68a65 100644
--- a/node_modules/websocket/lib/WebSocketConnection.js
+++ b/node_modules/websocket/lib/WebSocketConnection.js
@@ -32,9 +32,13 @@ const STATE_ENDING = 'ending';
 // Connection is fully closed.  No further data can be sent or received.
 const STATE_CLOSED = 'closed';
 
-var setImmediateImpl = ('setImmediate' in global) ?
-                            global.setImmediate.bind(global) :
-                            process.nextTick.bind(process);
+if ('setImmediate' in global) {
+    var setImmediateImpl = global.setImmediate.bind(global);
+} else if (typeof process !== 'undefined' && process.nextTick) {
+    var setImmediateImpl = process.nextTick.bind(process);
+} else {
+    var setImmediateImpl = function(fn) { setTimeout(fn, 0); };
+}
 
 var idCounter = 0;

Not sure if this code works because I don't use Realtime in my project, but it fixed the issue for me.

felipemarcos avatar Jul 10 '23 00:07 felipemarcos

Having the same issue. Thanks @felipemarcos your patch seems to help! (not using realtime myself either)

alatalo avatar Oct 29 '23 11:10 alatalo