fix(core): do not close connection by inactivity when there are pending queries

This commit is contained in:
alina 🌸 2023-12-23 21:58:36 +03:00
parent fb61bdc9f7
commit ca1916c5cb
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI

View file

@ -1473,6 +1473,24 @@ export class SessionConnection extends PersistentConnection {
protected _onInactivityTimeout() {
// we should send all pending acks and other service messages
// before dropping the connection
// additionally, if we are still waiting for some rpc results,
// we should wait for them first
let hasPendingRpc = false
for (const it of this._session.pendingMessages.values()) {
if (it._ === 'rpc') {
hasPendingRpc = true
break
}
}
if (hasPendingRpc) {
this.log.debug('waiting for pending rpc queries to finish before closing connection')
this._rescheduleInactivity()
return
}
if (!this._session.hasPendingMessages) {
this.log.debug('no pending service messages, closing connection')