kritzware/twitch-bot

lib/parser.js formatPRIVMSG: Cannot read property 'split' of undefined

TheBlackParrot opened this issue · 9 comments

C:\Users\TheBlackParrot\Documents\Share\twitch-plays-bj2\node_modules\twitch-bot\lib\parser.js:33
    parsed.username = username.split('!')[0]
                               ^

TypeError: Cannot read property 'split' of undefined
    at Object.formatPRIVMSG (C:\Users\TheBlackParrot\Documents\Share\twitch-plays-bj2\node_modules\twitch-bot\lib\parser.js:33:32)
    at TLSSocket.irc.on.data (C:\Users\TheBlackParrot\Documents\Share\twitch-plays-bj2\node_modules\twitch-bot\lib\bot.js:77:32)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:246:13)
    at TLSSocket.Readable.push (_stream_readable.js:208:10)
    at TLSWrap.onread (net.js:607:20)

Any chance to get more information about the version and the input that failed to be parsed?

Any updates on this @TheBlackParrot ?

Haven't seen it happen again recently, and I had no logs at the time. I've got it running under PM2 now so if it happens again I should be able to catch logs of what was going on.
Is there a debug output I can enable if it happens again?

I had this happen today:

...\node_modules\twitch-bot\lib\parser.js:33
    parsed.username = username.split('!')[0]
                               ^

TypeError: Cannot read property 'split' of undefined
    at Object.formatPRIVMSG (C:\...\node_modules\twitch-bot\lib\parser.js:33:32)
    at TLSSocket.irc.on.data (C:\...\node_modules\twitch-bot\lib\bot.js:77:32)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:246:13)
    at TLSSocket.Readable.push (_stream_readable.js:208:10)
    at TLSWrap.onread (net.js:597:20)

I got this error when someone "raided" (fucntionality of twitch) my stream, hopfuly this info is helpful.

What version of the bot are you using? You can find out this information by looking at the version no. in your package.json file of your project.

@kritzware Version 1.2.5

I get the same error when anyone hosts me

version: "twitch-bot": "^1.2.5"

node_modules\twitch-bot\lib\parser.js:33
    parsed.username = username.split('!')[0]
                               ^

TypeError: Cannot read property 'split' of undefined
    at Object.formatPRIVMSG (D:\hayesmaker\Workspace\twitch\chillstrim\chillstri                           m-server\node_modules\twitch-bot\lib\parser.js:33:32)
    at TLSSocket.irc.on.data (D:\hayesmaker\Workspace\twitch\chillstrim\chillstr                           im-server\node_modules\twitch-bot\lib\bot.js:77:32)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:246:13)
    at TLSSocket.Readable.push (_stream_readable.js:208:10)
    at TLSWrap.onread (net.js:597:20)
mrov commented

Same error here "version": "1.2.5"

server_1    |     parsed.username = username.split('!')[0]
server_1    |                                ^
server_1    |
server_1    | TypeError: Cannot read property 'split' of undefined
server_1    |     at Object.formatPRIVMSG (/app/node_modules/twitch-bot/lib/parser.js:33:32)
server_1    |     at TLSSocket.<anonymous> (/app/node_modules/twitch-bot/lib/bot.js:76:32)
server_1    |     at TLSSocket.emit (events.js:210:5)
server_1    |     at addChunk (_stream_readable.js:308:12)
server_1    |     at readableAddChunk (_stream_readable.js:285:13)
server_1    |     at TLSSocket.Readable.push (_stream_readable.js:223:10)
server_1    |     at TLSWrap.onStreamRead (internal/stream_base_commons.js:182:23)```

Has the same issiue and whole node crashed on it......

Just check after split if there is an index 0 not get it straight.
For simple fix try ```parsed.username = username.split('!')[0] || ''`
Or set parsed.username default to = '' (empty String)

I will try to fix it when i got more time...

Best Dan