twitch-bot icon indicating copy to clipboard operation
twitch-bot copied to clipboard

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

Open TheBlackParrot opened this issue 7 years ago • 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)

TheBlackParrot avatar Apr 03 '18 05:04 TheBlackParrot

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

PBug90 avatar Apr 06 '18 13:04 PBug90

Any updates on this @TheBlackParrot ?

kritzware avatar Apr 09 '18 09:04 kritzware

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?

TheBlackParrot avatar Apr 10 '18 07:04 TheBlackParrot

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.

Buggitt avatar Jul 01 '18 06:07 Buggitt

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 avatar Jul 01 '18 17:07 kritzware

@kritzware Version 1.2.5

Buggitt avatar Jul 02 '18 03:07 Buggitt

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)

hayesmaker avatar Aug 30 '18 20:08 hayesmaker

Same error here "version": "1.2.5"

mrov avatar Nov 06 '18 01:11 mrov

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

Dandrum avatar Oct 26 '19 06:10 Dandrum