Skip to content

Commit

Permalink
imap notifier add optional chaining + fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
NickOvt committed Jan 9, 2025
1 parent 4721069 commit ea11bb9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/imap-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class ImapNotifier extends EventEmitter {
}

let rlkey = 'lim:' + data.service;
const { closed: socketClosed, connecting, destroyed } = data.session.socket;
const { closed: socketClosed, connecting, destroyed } = data.session?.socket || {};

if (!socketClosed && !connecting && !destroyed) {
// socket alive, not closed
Expand All @@ -411,7 +411,7 @@ class ImapNotifier extends EventEmitter {
return callback(null, true);
});
} else {
// socket dead/closed
// socket dead/closed/undefined
const err = new Error('[ALERT] Socket closed unexpectedly before authentication completed.');
err.response = 'NO';
return callback(err, false);
Expand Down

0 comments on commit ea11bb9

Please sign in to comment.