Skip to content

Support connect/reconnect #190

@ITsPro-CN

Description

@ITsPro-CN

Environment

Node.js: 22.14.0
Nuxt: 4.1.3

Reproduction

  • nuxt.config.ts
export default defineNuxtConfig({
    nitro: {
    	experimental: {
    		database: true,
    	},
    	database: {
    		default: {
    			connector: "postgresql",
    			options: {
    				host: "container-name",
    				port: 5432,
    				user: "...",
    				password: "...",
    				database: "..."
    			},
    		}
    	}
  }
})
  • /server/api/index.ts
export default defineEventHandler(async (event) => {
	const db = useDatabase();
	const {rows} = await db.sql`...`;
	return rows;
});

Describe the bug

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),

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions