502 server error with supabase, no problem from localhost

Hi, I am having a problem with deployment with supabase access by supabase client (@supabase/supabase-js).
netlify site: https://rpg-store.netlify.app/
github: GitHub - norama/rpg-store

in browser: error decoding lambda response: invalid status code returned from lambda: 0
in network: GET https://rpg-store.netlify.app/ 502

No problem if I use inmemory lowdb instead of supabase.
No problem even with supabase from dev mode localhost.

I thought of environment variable problems but the same problem occurs with hardcoded values (database URL, api key).

Where are the console.logs on netlify? It would be of great help but I am not able to find that output.

Can you help me with this?
Thank you.

Right here: Netlify App

That error usually means you did not send a return statement with a statusCode.

Since you’re using Astro, this could also be an Astro bug as you don’t seem to be using Netlify Functions yourself, which would mean that Astro is building one for you.

Thanks for the log location, I have investigated this issue further, but without success.
Tried to replace dynamic import by static and at least this gave the following error in the browser:

Then I tried to add this bufferutil dependency explicitly to my project with pnpm i
but it did not help at all.

Then I tried to switch to edge-functions and I got the build error here:

5:35:09 PM: [commonjs--resolver] Cannot bundle Node.js built-in "node:fs/promises" imported from "node_modules/.pnpm/lowdb@4.0.1/node_modules/lowdb/lib/adapters/TextFile.js". Consider disabling ssr.noExternal or remove the built-in dependency.

But I do not know how to disable ssr.noExternal and if this is the way to go…

Can you help? Thanks.

Not sure what’s happening for your site, @norama.

I cloned your repo: https://github.com/Hrishikesh-K/rpg-store (deleted all the test stuff, but it shouldn’t matter) and deployed it here: https://superlative-pie-0b5d2b.netlify.app/, it works fine (at least in non-edge function mode, I did not test the edge-function mode).

1 major difference though, I used npm instead of pnpm. Maybe you can try that too?

Thanks a LOT.
I changed the whole build to npm and this solved the problem.
I had to do this both on netlify and locally, it was not enough just on netlify,
possibly due to the lock file (pnpm package lock has a different name as npm package lock).
Now this is working :slight_smile:

Hi @norama! Thanks for coming back to the forums! :wave:t6: Thank you for letting us know what helped you solve your problem! This will help other users who come across this post as they work to troubleshoot and debug their own work. :netliconfetti: We really appreciate this! Happy Building. :smiling_face_with_three_hearts: