Skip to content

Commit 1d25d3b

Browse files
Remove ping timer on socket close (#314)
1 parent 73a8599 commit 1d25d3b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/client.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,12 @@ module.exports = class IrcClient extends EventEmitter {
331331

332332
// Browsers have started throttling looped timeout callbacks
333333
// using the pong event to set the next ping breaks this loop
334-
this.command_handler.on('pong', resetPingTimer);
334+
client.command_handler.on('pong', resetPingTimer);
335+
336+
// Socket has disconnected, remove 'pong' listener until next 'registered' event
337+
client.connection.once('socket close', () => {
338+
client.command_handler.off('pong', resetPingTimer);
339+
});
335340

336341
// Start timer
337342
resetPingTimer();

0 commit comments

Comments
 (0)