You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Nitro's experimental features in Nuxt4 and often get errors a few hours after the service starts.
H3Error: Client has encountered a connection error and is not queryable
at /app/.output/server/node_modules/.pnpm/pg@8.16.3/node_modules/pg/lib/client.js:545:17
... 5 lines matching cause stack trace ...
at async Server.toNodeHandle (file:///app/.output/server/chunks/nitro/nitro.mjs:1934:7) {
cause: Error: Client has encountered a connection error and is not queryable
at /app/.output/server/node_modules/.pnpm/pg@8.16.3/node_modules/pg/lib/client.js:545:17
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async StatementWrapper.all (file:///app/.output/server/chunks/nitro/nitro.mjs:5436:15)
at async Object.sql (file:///app/.output/server/chunks/nitro/nitro.mjs:5338:18)
at async Object.handler (file:///app/.output/server/chunks/routes/api/index.get.mjs:16:28)
at async Object.handler (file:///app/.output/server/chunks/nitro/nitro.mjs:1663:19)
at async Server.toNodeHandle (file:///app/.output/server/chunks/nitro/nitro.mjs:1934:7),
@systems-center Thanks for the reminder. I’ll check and see what I can do.
I recommend adopting the pool version, as it resolves the 'not queryable' issue simply by setting maxIdle: 0. And be cautious of the limitation on transactions with the pool connection.
I’ve submitted PR #203, which adds pool connectors for both mysql2and pg-nodejs. The complete connector code changes are available.
Activity
ITsPro-CN commentedon Oct 25, 2025
In Nuxt4, each time I use
useDatabase()returns the same instance, and I cannot find an elegant way to auto-reconnect.Tried
End in
This database instance has been disposed and cannot be used.Or
Also end in
Error: Client has encountered a connection error and is not queryable[-]PostgreSQL: Client has encountered a connection error and is not queryable[/-][+]Support connect/reconnect[/+]pi0 commentedon Oct 25, 2025
Thanks for issue. We should introduce a way to allow reconnecting instances indeed.
ITsPro-CN commentedon Oct 25, 2025
Thanks a lot. I will use a proxy for now. Looking forward to the update.
systems-center commentedon Dec 4, 2025
this will also help me a lot
see:#175
thanks
ITsPro-CN commentedon Dec 18, 2025
For Nuxt, simply overwrite the useDatabase function.
/server/utils/db/db.ts/server/utils/db/connectors/mysql2.ts/server/utils/db/connectors/statement.tsAnd replace the Nitro experimental Configuration with:
Also, there is a pool version:
systems-center commentedon Dec 24, 2025
Thank you very much
I will try soon
By the way,
the MYSQL2 package has released v3.16.0 in which they added a state getter to track connection lifecycle status
ITsPro-CN commentedon Dec 26, 2025
@systems-center Thanks for the reminder. I’ll check and see what I can do.
I recommend adopting the pool version, as it resolves the 'not queryable' issue simply by setting
maxIdle: 0. And be cautious of the limitation on transactions with the pool connection.I’ve submitted PR #203, which adds pool connectors for both mysql2and pg-nodejs. The complete connector code changes are available.