pg-logical-replication
pg-logical-replication copied to clipboard
Don't use async methods in sync handlers.
Invoking async methods in synchronous event handlers (see example below) can lead to unhandled rejections which can trigger fatal application restarts.
if (this.config.acknowledge.timeoutSeconds > 0 && enable)
this.checkStandbyStatusTimer = setInterval(async () => {
if (this._stop)
return;
if (this._lastLsn &&
Date.now() - this.lastStandbyStatusUpdatedTime > this.config.acknowledge.timeoutSeconds * 1000)
await this.acknowledge(this._lastLsn);
}, 1000);
Any async handler should catch all exceptions or avoid async and ensure the invoked promise has a catch handler.
@jmealo Hello. Could you submit your improvement as a PR? Thank you.