Next.js Discord

Discord Forum

@vercel/postgres' sql fails to fetch

Unanswered
Alaska pollock posted this in #help-forum
Open in Discord
Alaska pollockOP
Howdy, folks.
I started the next-js dashboard tutorial yesterday, but even though everything else seems fine, my sql function imported from @vercel/postgres is failing. I can connect when using db.connect without issues, but I can't find out why sql doesn't connect.
error message is pretty bland and I couldn't figure out how to trace it

I got around that by opening and releasing a client everytime I need to fetch something from the DB, but I rather not have to do that and instead fix sql. is that reasonable?

error message: [ Server ] NeonDbError: Error connecting to database: fetch failed
repo, for refence: https://github.com/jporfirio/nextjs-dashboard
repo at commit that uses sql: https://github.com/jporfirio/nextjs-dashboard/blob/c74fa4f537838b8f2a6835f76af3ac0a88db2b61/app/lib/data.ts
tutorial, for reference: https://nextjs.org/learn/dashboard-app/fetching-data#using-sql
database I picked was Supabase on free tier, Neon gave the same error

8 Replies

@"use middleware" you'll likely have to increase timeout
Alaska pollockOP
I was initially excited about it being a simple timeout, but I couldn't find mention of timeout on the @vercel/postgres npm page, and supabase doens't log any timeout (reference doc https://supabase.com/docs/guides/database/postgres/timeouts)
it shouldn't be a timeout problem on supabase anyway, because the query works if I open the connection instead of doing just sql
still lost, but thanks for trying
@Alaska pollock could you tell me how you increased the timeout?
db.connect must have some arg options
Also, I only got this error on development, and on production, it worked just fine
@"use middleware" db.connect must have some arg options
Just type time and press CTRL+Space
Alaska pollockOP
I might have missed something, because when using the sql function I didn't see it requiring a connect call before. I'll read the docs again to make sure I didn't miss something the first 5 times I read it
using connect doesn't break the call, it works fine without specifying timeout.