martynsmith / node-irc

NodeJS IRC client library
GNU General Public License v3.0
1.32k stars 425 forks source link

TypeError: Cannot read property 'requestedDisconnect' of null #485

Open paladox opened 7 years ago

paladox commented 7 years ago

Hi I got this error

TypeError: Cannot read property 'requestedDisconnect' of null at Client.send (/data/project/lolrrit-wm/lolrrit-wm/node_modules/irc/lib/irc.js:932:19) at dequeue (/data/project/lolrrit-wm/lolrrit-wm/node_modules/irc/lib/irc.js:962:22) at wrapper [as _onTimeout] (timers.js:275:11) at Timer.listOnTimeout (timers.js:92:15)

ahti123 commented 7 years ago

Possible fix proposed in #477

paladox commented 7 years ago

Oh thankyou

jascott1 commented 7 years ago

I manually applied the patch in #477 to solve this 'requestedDisconnect' issue but I am still seeing the same behavior.

paladox commented 7 years ago

@ahti123 looking at that, that shows a different error compared to here.

There it says 'readyState' whereas here shows 'requestedDisconnect'

ahti123 commented 7 years ago

Yep, my bad, I have a "TypeError: Cannot read property 'requestedDisconnect' of null" too and the fix I pointed here does not work for me, too :)

jascott1 commented 7 years ago

This is working for me so far but I have not looked into it for any consequences.

diff --git a/irc.js b/irc.js
index 5a21d0a..28abcd9 100644
--- a/irc.js
+++ b/irc.js
@@ -935,7 +935,7 @@ Client.prototype.send = function(command) {
     if (this.opt.debug)
         util.log('SEND: ' + args.join(' '));

-    if (this.conn && this.conn.requestedDisconnect) {
+    if (this.conn && !this.conn.requestedDisconnect) {
         this.conn.write(args.join(' ') + '\r\n');
     }
 };
koooge commented 7 years ago

Also seen a similar issue with node-irc v0.5.2 and node v6.9.1.

TypeError: Cannot read property 'requestedDisconnect' of null
    at Client.send (/path/to/node_modules/irc/lib/irc.js:936:19)
    at Timeout.dequeue [as _onTimeout] (/path/to/node_modules/irc/lib/irc.js:966:22)
    at ontimeout (timers.js:365:14)
    at tryOnTimeout (timers.js:237:5)
    at Timer.listOnTimeout (timers.js:207:5)

But, I could avoid this by using node-irc v0.3.7