umami
umami copied to clipboard
Unhandled Promise Rejection on Vercel + Supabase
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
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
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.
@yvanlok Did you figure this out? I too am getting the same problem and I tried adding pgbouncer. Vercel and Supabase deployment.
Just reviewing the docs here. Did you update the prisma schema file and add the DIRECT_DATABASE_URL?
@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!
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.
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?
https://github.com/yvanlok/umami/blob/master/db/postgresql/schema.prisma I did indeed do that, but it still didn't work.
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.