evanyeung / terminal-slack

Terminal client for slack
MIT License
1.03k stars 78 forks source link

TypeError: Cannot read property 'name' of undefined #32

Closed laxdog closed 7 years ago

laxdog commented 7 years ago

Running on OSX 10.12.2, node v7.4.0

It's happening when I try to use the slack plugin meekan, when I try to set up a meeting the bot's response kills the client. I've attached a screenshot of the response that did it.

screen shot 2017-01-31 at 4 16 25 pm
TypeError: Cannot read property 'name' of undefined
    at handleNewMessage (/Users/mrobinson/source/slack-cli/terminal-slack/main.js:56:5)
    at WebSocket.<anonymous> (/Users/mrobinson/source/slack-cli/terminal-slack/main.js:81:7)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:191:7)
    at Receiver.ontext (/Users/mrobinson/source/slack-cli/terminal-slack/node_modules/ws/lib/WebSocket.js:797:10)
    at /Users/mrobinson/source/slack-cli/terminal-slack/node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (/Users/mrobinson/source/slack-cli/terminal-slack/node_modules/ws/lib/Receiver.js:360:5)
    at /Users/mrobinson/source/slack-cli/terminal-slack/node_modules/ws/lib/Receiver.js:462:14
    at Receiver.flush (/Users/mrobinson/source/slack-cli/terminal-slack/node_modules/ws/lib/Receiver.js:336:3)
    at Receiver.finish (/Users/mrobinson/source/slack-cli/terminal-slack/node_modules/ws/lib/Receiver.js:478:12)
evanyeung commented 7 years ago

Hi @laxdog, thanks for the heads up. It looks some bots can post without their user showing up in the user list. I looked into it quickly and it looks like bots should be returned by users.list but I guess not all bots are. Or at least, it breaks responses from bots with special integrations like buttons (which aren't supported in the terminal right now).

I've added a fix in commit 2b9982fae74e05c60c305d0d19e4eaaec695465b that shows "Unknown User" if the user is not found. This should at least allow you to keep using the app for now.

laxdog commented 7 years ago

Thanks! Seems to be working well now.

sjcalamia commented 7 years ago

Shall we open another issue for the "Unknown User" showing up? It seems that between the CircleCI bot and the Github bot it shows none of the text and none of the users, and that's the majority of the traffic I need to see, so this fix effectively breaks slack for me anyways. :/

Thank you much for looking into it!