Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors when parsing message #64

Closed
tapichu opened this issue Nov 14, 2011 · 6 comments · Fixed by #68
Closed

Handle errors when parsing message #64

tapichu opened this issue Nov 14, 2011 · 6 comments · Fixed by #68

Comments

@tapichu
Copy link
Contributor

tapichu commented Nov 14, 2011

I'm getting this error sporadically with irc 0.3.2:

2011-11-14T07:32:37+00:00 app[app.1]: /app/node_modules/hubot/node_modules/irc/lib/irc.js:715
2011-11-14T07:32:37+00:00 app[app.1]:     message.command = match[1];
2011-11-14T07:32:37+00:00 app[app.1]:                            ^
2011-11-14T07:32:37+00:00 app[app.1]: TypeError: Cannot read property '1' of null
2011-11-14T07:32:37+00:00 app[app.1]:     at parseMessage (/app/node_modules/hubot/node_modules/irc/lib/irc.js:715:28)
2011-11-14T07:32:37+00:00 app[app.1]:     at /app/node_modules/hubot/node_modules/irc/lib/irc.js:506:27
2011-11-14T07:32:37+00:00 app[app.1]:     at Array.forEach (native)
2011-11-14T07:32:37+00:00 app[app.1]:     at Socket.<anonymous> (/app/node_modules/hubot/node_modules/irc/lib/irc.js:505:15)
2011-11-14T07:32:37+00:00 app[app.1]:     at Socket.emit (events.js:64:17)
2011-11-14T07:32:37+00:00 app[app.1]:     at Socket._onReadable (net.js:671:31)
2011-11-14T07:32:37+00:00 app[app.1]:     at IOWatcher.onReadable [as callback] (net.js:177:10)

And the problem is that match can be null under some circumstances (which I haven't pinned down yet).

// Parse command
match = line.match(/^([^ ]+) +/);
message.command = match[1];

Maybe wrapping https://github.com/martynsmith/node-irc/blob/master/lib/irc.js#L506-513 with an if ( line.trim() != '' ) could fix it?

@martynsmith
Copy link
Owner

Hmmm, failing that far down in the message parsing strikes me as very odd.

Are you able to give me some connection details to the specific IRC server that's causing those issues (and I'll take a closer look).

Thanks,

@tapichu
Copy link
Contributor Author

tapichu commented Nov 16, 2011

I'm using https://grove.io/

I've been unable to debug it properly because the code is deployed on heroku, but I think I've managed to replicate the error on a consistent basis. Tonight I'll set it up at home, with some console.log statements to see what's going on.

Cheers

@tapichu
Copy link
Contributor Author

tapichu commented Nov 16, 2011

It looks like the problem occurs with the QUIT command, when I close my IRC client. I've tested with Konversation and with Quassel and it's happening with both.

@tapichu
Copy link
Contributor Author

tapichu commented Nov 17, 2011

I ran it at home and the problem is here:

match = line.match(/^([^ ]+) +/);
message.command = match[1];

At this point, line is exactly 'QUIT', with no trailing whitespace, so there's no match and the next line fails because match is null.

@leah
Copy link

leah commented Jan 31, 2012

Hey! I just wanted to let you know that I've added an extra space after the QUIT command. Actually, I've added a space after any command that contains no params or message. I think that should help with the parsing.

@tapichu
Copy link
Contributor Author

tapichu commented Feb 18, 2012

👍

Half-Shot referenced this issue in matrix-org/node-irc Feb 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants