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
Add optional callback for handling terminal reconnection failures
that occur asynchronously after a connection drop. The callback is
only invoked for async errors — initial connect() failures are
handled via the rejected promise directly.
Also fixes Error cause being passed incorrectly (now uses { cause: err })
and ensures _reconnect() promise rejections are properly caught.
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,6 +71,7 @@ import PGPubSub from 'pg-notify'
71
71
-`options` (`object`) Configuration options for pg-notify pubsub instance. Accepts same options as [pg](https://github.com/brianc/node-postgres) with few custom ones described below.
72
72
- reconnectMaxRetries (`number`) Maximum number of reconnect attempts after losing connection. Pass `0` to disable reconnecting. Default: `10`.
73
73
- maxPayloadSize (`number`) Maximum payload size, exceeding given size will throw an error. Default: `7999` ([In the default configuration it must be shorter than 8000 bytes.](https://www.postgresql.org/docs/current/sql-notify.html)).
74
+
- onConnectionError (`function`) Optional callback invoked with the error when reconnection fails after exhausting all retries. Only called for errors that occur asynchronously after a connection drop, preventing the process from crashing with an uncaught exception. Not called during the initial `connect()` — handle that via the rejected promise directly.
0 commit comments