Skip to content

Commit

Permalink
fix(socket): Use destroy() instead of destroySoon()
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Jul 6, 2024
1 parent 0280ca9 commit 830c2d1
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions lib/imap-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,11 +768,7 @@ class ImapFlow extends EventEmitter {
this.writeSocket.destroySoon = () => {
try {
if (this.socket) {
if (typeof this.socket.destroySoon === 'function') {
this.socket.destroySoon();
} else {
this.socket.destroy();
}
this.socket.destroy();
}
this.writeSocket.end();
} catch (err) {
Expand Down Expand Up @@ -1484,23 +1480,15 @@ class ImapFlow extends EventEmitter {

if (this.writeSocket && !this.writeSocket.destroyed) {
try {
if (typeof this.writeSocket.destroySoon === 'function') {
this.writeSocket.destroySoon();
} else {
this.writeSocket.destroy();
}
this.writeSocket.destroy();
} catch (err) {
this.log.error({ err, cid: this.id });
}
}

if (this.socket && !this.socket.destroyed && this.writeSocket !== this.socket) {
try {
if (typeof this.socket.destroySoon === 'function') {
this.socket.destroySoon();
} else {
this.socket.destroy();
}
this.socket.destroy();
} catch (err) {
this.log.error({ err, cid: this.id });
}
Expand Down

0 comments on commit 830c2d1

Please sign in to comment.