From d06071b8c592944b56a942402e492c9f4eddca0b Mon Sep 17 00:00:00 2001 From: titanism <101466223+titanism@users.noreply.github.com> Date: Mon, 29 Jul 2024 03:42:50 -0500 Subject: [PATCH] fix: fixed callback invocations to check if session already closed (#705) --- lib/pop3/connection.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/pop3/connection.js b/lib/pop3/connection.js index 1e4b709c..d03aee95 100644 --- a/lib/pop3/connection.js +++ b/lib/pop3/connection.js @@ -727,6 +727,11 @@ class POP3Connection extends EventEmitter { } this._server.onFetchMessage(message, this.session, (err, stream) => { + if (!this.session) { + // already closed, do nothing + return; + } + if (err) { this._server.loggelf({ short_message: '[POP3RETR] error', @@ -810,6 +815,11 @@ class POP3Connection extends EventEmitter { } this._server.onFetchMessage(message, this.session, (err, stream) => { + if (!this.session) { + // already closed, do nothing + return; + } + if (err) { this._server.loggelf({ short_message: '[POP3TOP] error', @@ -1002,6 +1012,11 @@ class POP3Connection extends EventEmitter { openMailbox(next) { this._server.onListMessages(this.session, (err, listing) => { + if (!this.session) { + // already closed, do nothing + return; + } + if (err) { this.logger.info( {