diff --git a/changelog.d/115.bugfix b/changelog.d/115.bugfix new file mode 100644 index 00000000..ba0340a4 --- /dev/null +++ b/changelog.d/115.bugfix @@ -0,0 +1 @@ +Fix reconnect loop due to the close listener being called on socket destruction. diff --git a/src/irc.ts b/src/irc.ts index 80eb972f..a85769ac 100644 --- a/src/irc.ts +++ b/src/irc.ts @@ -1272,6 +1272,7 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter TypedEmitter { + this.conn?.removeAllListeners(evtType); + }); + } + private reconnect(retryCount: number) { if (!this.isOurSocket) { // Cannot reconnect if the socket is not ours. @@ -1455,11 +1464,7 @@ export class Client extends (EventEmitter as unknown as new () => TypedEmitter { - this.conn?.removeAllListeners(evtType); - }); + this.unbindListeners(); if (this.isOurSocket) { this.disconnect(); }