gf3 / IRC-js

The best IRC library for node.js
http://irc-js.com
The Unlicense
179 stars 33 forks source link

Cannot read property 'command' of undefined #63

Closed edsu closed 11 years ago

edsu commented 11 years ago

I get this error periodically when an incoming message fails to parse:

/home/ed/Projects/wikichanges/node_modules/irc-js/lib/irc.js:131
      emitter.emit( message.command, message )
                           ^
TypeError: Cannot read property 'command' of undefined
    at IRC.parseMessage (/home/ed/Projects/wikichanges/node_modules/irc-js/lib/irc.js:131:28)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
    at TCP.onread (net.js:526:21)

Here is a sample program that connects to a bunch of Wikipedia update IRC channels, which should throw the error for you, if you let it run for 30 seconds or so:

var irc = require('irc-js')

var channels = ['#vo.wikipedia', '#lt.wikipedia', '#id.wikipedia', '#de.wikipedia', '#uk.wikipedia', '#el.wikipedia', '#eo.wikipedia', '#ar.wikipedia', '#tr.wikipedia', '#he.wikipedia', '#ru.wikipedia', '#fi.wikipedia', '#eu.wikipedia', '#sl.wikipedia', '#nl.wikipedia', '#pl.wikipedia', '#sv.wikipedia', '#cs.wikipedia', '#pt.wikipedia', '#ro.wikipedia', '#it.wikipedia', '#sk.wikipedia', '#ca.wikipedia', '#no.wikipedia', '#es.wikipedia', '#ko.wikipedia', '#hu.wikipedia', '#fa.wikipedia', '#zh.wikipedia', '#fr.wikipedia', '#ja.wikipedia', '#bg.wikipedia', '#ms.wikipedia', '#en.wikipedia', '#commons.wikimedia', '#vi.wikipedia', '#da.wikipedia', '#wikidata.wikipedia']

var client = new irc({
      server: 'irc.wikimedia.org',
      port: 8001,
      nick: 'testtesttest',
      log: false
    });

client.connect(function () {
  client.join(channels)
  client.on('privmsg', function(msg) {
    console.log(msg)
  });
});
gf3 commented 11 years ago

Hey there, could you also provide me with the exact version of node and IRC-js you're using?

edsu commented 11 years ago

My bad I was on an old version, v0.2.