porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.09k stars 259 forks source link

Error Message Error: write CONNECT_TIMEOUT with BUN #749

Open approached opened 7 months ago

approached commented 7 months ago

Hi @ all

I'm a bit frustrated. I use bun + elysiajs + drizzle ORM + docker and have a cronjob every 5 minutes. I get an error every now and then without a recognisable pattern:

Error Error {
  stack: "Error: write CONNECT_TIMEOUT postgres13:5432\n    at connection 
(/app/node_modules/postgres/src/errors.js:26:9)\n    at connectTimedOut 
(/app/node_modules/postgres/src/connection.js:256:19)\n    at done 
(/app/node_modules/postgres/src/connection.js:1016:12)",
  query: undefined,
  parameters: undefined,
  args: [ "ACTIVE", false, "2023-12-02T04:25:00", "2023-12-02T04:29:59" ],
  types: null,
  message: "write CONNECT_TIMEOUT postgres13:5432",
  code: "CONNECT_TIMEOUT",
  errno: "CONNECT_TIMEOUT",
  address: "postgres13",
  port: 5432,
  toString: [Function: toString],
  name: "Error"

My query looks like:

const items: AppointmentParticipant[] | unknown =
            await db.query.appointments.findMany({
                where: and(
                    eq(appointments.status, "ACTIVE"),
                    eq(appointments.isDecline, false),
                    between(appointments.notificationAt, filterFrom, filterTo),
                ),
                with: {
                    appointmentParticipants: true,
                },
            });

If the error has occurred then no further query can be created. The PostgresSQL database itself does not give an error message. The user uses a connection limit: -1.

Does anyone have an idea how I can debug it better? Or an idea what the problem could be?

wackfx commented 7 months ago

This issue is already patched on #738 and will be released soon.

jonahsnider commented 5 months ago

When is this going to be released? Currently having this issue in one of my apps and would really appreciate a more concrete schedule on when users can expect a fix.