Skip to content

Commit

Permalink
fix: fixed socket check (returning false positive)
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Oct 10, 2024
1 parent 64e2c44 commit 7f57edb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions helpers/on-auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ async function onAuth(auth, session, fn) {
if (this.server instanceof IMAPServer) {
const socket =
(session.socket && session.socket._parent) || session.socket;
if (!socket || socket?.destroyed || socket?.readyState !== 'open')
throw new SocketError();
if (!socket || socket?.destroyed || socket?.readyState !== 'open') {
const err = new SocketError();
err.isCodeBug = true;
err.socket = socket;
err.session = session;
this.logger.fatal(err);
// throw err; // TODO: investigate why socket error occurs here
}
}

// override session.getQueryResponse (safeguard)
Expand Down
10 changes: 8 additions & 2 deletions helpers/refresh-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ async function refreshSession(session, command) {
this?.constructor?.name !== 'CalDAV'
) {
const socket = (session.socket && session.socket._parent) || session.socket;
if (!socket || socket?.destroyed || socket?.readyState !== 'open')
throw new SocketError();
if (!socket || socket?.destroyed || socket?.readyState !== 'open') {
const err = new SocketError();
err.isCodeBug = true;
err.socket = socket;
err.session = session;
this.logger.fatal(err);
// throw err; // TODO: investigate why socket error occurs here
}
}

if (!isSANB(session?.user?.domain_id) || !isSANB(session?.user?.domain_name))
Expand Down

0 comments on commit 7f57edb

Please sign in to comment.