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 believe the key problem here is the "subscribe" creates a temporary replication slot on the database. As soon as the database shuts down, that original replication slot is gone forever. Postgres.js at the moment is not smart enough to recreating a new replication slot when the database is back online.
@porsager What is really problematic at the moment is that there is no way for us to handle it ourselves in this situation. As the error is being completely swallowed by the stream here.
console.error('Unexpected error during logical streaming - reconnecting',e)
}
I think even just rethrow the error would be better. Because then I can catch that error using the global "UncaughtException" event. And even if I don't, the program would completely crash and restarted by the container runtime or process manager alike.
Reacted by Vladimir Dronnikov, Sveinung Tord Røsaker, smartcrash, Hans Zoons and paul
Ran into the same issue. The database connection itself gets reinstated automatically, but the subscription is never recreated without a full client restart.
In v4 sql.subscribe reconnects with a backoff after the connection closes, and the error goes to the onerror callback (the fourth argument) instead of an unhandled CONNECTION_CLOSED; without one it's logged. onsubscribe is called again after each reconnect.
Activity
Louis-Tian commentedon Jan 10, 2024
Just got caught with the same error. And it's causing my database to bloat with the WAL piling up...
Louis-Tian commentedon Jan 19, 2024
I believe the key problem here is the "subscribe" creates a temporary replication slot on the database. As soon as the database shuts down, that original replication slot is gone forever. Postgres.js at the moment is not smart enough to recreating a new replication slot when the database is back online.
@porsager What is really problematic at the moment is that there is no way for us to handle it ourselves in this situation. As the error is being completely swallowed by the stream here.
postgres/src/subscribe.js
Lines 99 to 107 in 6f20a48
I think even just rethrow the error would be better. Because then I can catch that error using the global "UncaughtException" event. And even if I don't, the program would completely crash and restarted by the container runtime or process manager alike.
dvv commentedon Jan 19, 2024
@Louis-Tian right.
I also drafted master...dvv:postgres:master to move "close" logic uplevel.
smartcrash commentedon Oct 11, 2024
I having this same issue. Have you found a work around for this?
X-43A commentedon Nov 7, 2024
Same issue. A solution would be appreciated. Thanks
hanszoons commentedon Dec 20, 2024
Ran into the same issue. The database connection itself gets reinstated automatically, but the subscription is never recreated without a full client restart.
pmielle commentedon Jul 27, 2025
hey, same issue here. Any solutions/workarounds? Thanks!
IAkumaI commentedon Jul 13, 2026
Any progress on this?
porsager commentedon Oct 29, 2026
In v4
sql.subscribereconnects with a backoff after the connection closes, and the error goes to theonerrorcallback (the fourth argument) instead of an unhandledCONNECTION_CLOSED; without one it's logged.onsubscribeis called again after each reconnect.