N
Neon•2y ago
afraid-scarlet

Nextjs Turbopack: NeonDbError: Error connecting to database: fetch failed

getting this error sporadically on my local, it'll spam a handful of them at a time.
NeonDbError: Error connecting to database: fetch failed
at execute (/home/***/.next/server/chunks/ssr/3d06b_@neondatabase_serverless_index_mjs_ad6191._.js:4910:21)
at async NeonHttpPreparedQuery.execute (/home/***/.next/server/chunks/ssr/687d2_drizzle-orm_bb01ce._.js:5651:24)
at async fetchProfile (/home/***/.next/server/chunks/ssr/[root of the server]__b45261._.js:1428:18)
at async /home/***/.next/server/chunks/ssr/[root of the server]__b45261._.js:1491:21
NeonDbError: Error connecting to database: fetch failed
at execute (/home/***/.next/server/chunks/ssr/3d06b_@neondatabase_serverless_index_mjs_ad6191._.js:4910:21)
at async NeonHttpPreparedQuery.execute (/home/***/.next/server/chunks/ssr/687d2_drizzle-orm_bb01ce._.js:5651:24)
at async fetchProfile (/home/***/.next/server/chunks/ssr/[root of the server]__b45261._.js:1428:18)
at async /home/***/.next/server/chunks/ssr/[root of the server]__b45261._.js:1491:21
only seems to happen when using turbopack, not with webpack. had a quick search in the server for anything to do with turbo to no avail. assuming this is a turbopack compatibility thing node: 20.11.0 next: 14.2.2 drizzle: ^0.30.9 @neondatabase/serverless: ^0.9.1
5 Replies
ambitious-aqua
ambitious-aqua•2y ago
Sounds like it could be Turbopack, but we've also seen some potential issues with Node.js v20. If you use Node.js 18 does it happen too?
afraid-scarlet
afraid-scarletOP•2y ago
it doesn't seem to, no. seems like you know about node 20 issues so nothing further from me then, all good 👍
ambitious-aqua
ambitious-aqua•2y ago
Interesting, this does add weight to the Node.js 20 theory
afraid-scarlet
afraid-scarletOP•2y ago
i do remember seeing something to do with undici changes in 20 not sure if that would have anything to do with it weirdly enough i do get sporadic "error connecting to database: fetch failed" errors in prod (vercel node 20) but i only have 2 in the last day, so its probably just http doing its thing whereas in dev/local it'll happen every other page load
ambitious-aqua
ambitious-aqua•2y ago
This is my hunch TBH. Something in the undici implementation is potentially causing issues. (Not suggesting that undici is broken, it could be that it's doing something correctly and old fetch or the serverless driver was reliant on that "broken" behaviour) Hmm, that's odd. I wonder if it's something with hotreload breaking connections

Did you find this page helpful?