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

Unhandled Promise Rejection on Vercel + Supabase #2647

Open
yvanlok opened this issue Apr 5, 2024 · 8 comments
Open

Unhandled Promise Rejection on Vercel + Supabase #2647

yvanlok opened this issue Apr 5, 2024 · 8 comments

Comments

@yvanlok
Copy link

yvanlok commented Apr 5, 2024

Describe the Bug

After checking Vercel Logs, I can often see that the root /api/websites/* is often getting this error with an error code 500. All the other routes work fine, but this route is often getting this error. It is a Vercel Serverless Function if that makes any difference.

Database

PostgreSQL

Relevant log output

Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"PrismaClientInitializationError: \nInvalid `prisma.user.findUnique()` invocation:\n\n\nCan't reach database server at `aws-0-eu-west-2.pooler.supabase.com`:`5432`\n\nPlease make sure your database server is running at `aws-0-eu-west-2.pooler.supabase.com`:`5432`.","reason":{"errorType":"PrismaClientInitializationError","errorMessage":"\nInvalid `prisma.user.findUnique()` invocation:\n\n\nCan't reach database server at `aws-0-eu-west-2.pooler.supabase.com`:`5432`\n\nPlease make sure your database server is running at `aws-0-eu-west-2.pooler.supabase.com`:`5432`.","name":"PrismaClientInitializationError","clientVersion":"5.9.1","stack":["PrismaClientInitializationError: ","Invalid `prisma.user.findUnique()` invocation:","","","Can't reach database server at `aws-0-eu-west-2.pooler.supabase.com`:`5432`","","Please make sure your database server is running at `aws-0-eu-west-2.pooler.supabase.com`:`5432`.","    at ai.handleRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:126:7075)","    at ai.handleAndLogRequestError (/var/task/node_modules/@prisma/client/runtime/library.js:126:6109)","    at ai.request (/var/task/node_modules/@prisma/client/runtime/library.js:126:5817)","    at async l (/var/task/node_modules/@prisma/client/runtime/library.js:131:9709)","    at async /var/task/.next/server/chunks/6688.js:1:16357"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: PrismaClientInitializationError: ","Invalid `prisma.user.findUnique()` invocation:","","","Can't reach database server at `aws-0-eu-west-2.pooler.supabase.com`:`5432`","","Please make sure your database server is running at `aws-0-eu-west-2.pooler.supabase.com`:`5432`.","    at process.<anonymous> (file:///var/runtime/index.mjs:1276:17)","    at process.emit (node:events:529:35)","    at emit (node:internal/process/promises:149:20)","    at processPromiseRejections (node:internal/process/promises:283:27)","    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)"]}
Unknown application error occurred

Which Umami version are you using? (if relevant)

No response

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel + Supabase

@franciscao633
Copy link
Collaborator

Not sure why its happening on a single route. Are you using ?pgbouncer=true&connection_limit=1 in your DATABASE_URL?

https://supabase.com/partners/integrations/prisma

@yvanlok
Copy link
Author

yvanlok commented Apr 5, 2024

Yes I am. I tried removing it but I still get the same problem. The only thing I can think of that was weird with my deployment was that I didn't update for a long time from around 9 months ago, and then suddenly updated to the newest version a few weeks ago and then the problems started appearing.

I'm thinking that the database was meant to have updated in earlier versions, but I skipped through them.

@BradNut
Copy link

BradNut commented May 3, 2024

@yvanlok Did you figure this out? I too am getting the same problem and I tried adding pgbouncer. Vercel and Supabase deployment.

@franciscao633
Copy link
Collaborator

Just reviewing the docs here. Did you update the prisma schema file and add the DIRECT_DATABASE_URL?

@BradNut
Copy link

BradNut commented May 3, 2024

@franciscao633 , I had not looked at Umami's docs in a while and didn't even see that. I just tried and doing this worked!

@yvanlok
Copy link
Author

yvanlok commented May 3, 2024

Just reviewing the docs here. Did you update the prisma schema file and add the DIRECT_DATABASE_URL?

Yes I had tried doing this already but I had no luck. I unfortunately already moved to Cloudflare Analytics as it was free and didn't require self-hosting.

@BradNut
Copy link

BradNut commented May 3, 2024

Just reviewing the docs here. Did you update the prisma schema file and add the DIRECT_DATABASE_URL?

Yes I had tried doing this already but I had no luck. I unfortunately already moved to Cloudflare Analytics as it was free and didn't require self-hosting.

That's odd because I think it's working fine for me after I manually changed my fork's schema.prisma file like so: https://github.com/BradNut/umami/blob/master/db/postgresql/schema.prisma#L8

Then you have two environmental variables in Vercel. That didn't work for you?

@yvanlok
Copy link
Author

yvanlok commented May 4, 2024

https://github.com/yvanlok/umami/blob/master/db/postgresql/schema.prisma
I did indeed do that, but it still didn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants