porsager / postgres

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

reconnect on disconnection from DB with subscriptions #980

Closed X-43A closed 1 week ago

X-43A commented 1 week ago

I'm using version 3.4.4.

My subscriptions stop working whenever they get a disconnection from the DB. Is there a way to reconnect after a certain time?

This is the error I get when a disconnection happens:

Unexpected error during logical streaming - reconnecting Error: write CONNECTION_CLOSED localhost:5432
    at Socket.closed (file:///Users/x/Desktop/company.nosync/app/ws/node_modules/postgres/src/connection.js:438:57)
    at Socket.emit (node:events:507:28)
    at TCP.<anonymous> (node:net:350:12)
    at new Query (file:///Users/x/Desktop/company.nosync/app/ws/node_modules/postgres/src/query.js:35:9)
    at Function.unsafe (file:///Users/x/Desktop/company.nosync/app/ws/node_modules/postgres/src/index.js:121:21)
    at init (file:///Users/x/Desktop/company.nosync/app/ws/node_modules/postgres/src/subscribe.js:90:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async file:///Users/x/Desktop/company.nosync/app/ws/server.js:257:32 {
  code: 'CONNECTION_CLOSED',
  errno: 'CONNECTION_CLOSED',
  address: [ 'localhost' ],
  port: [ 5432 ],
  query: "START_REPLICATION SLOT postgresjs_l0xikwtve0a LOGICAL 0/66FC6A0 (proto_version '1', publication_names 'messages')",
  parameters: [],
  args: [],
  types: []
}

Thank you

X-43A commented 1 week ago

Same as #757. Closing this