bkanber / Slackadaisical

Command line Slack chat client.
GNU General Public License v3.0
277 stars 14 forks source link

TypeError: Object.values is not a function #16

Open jwbensley opened 6 years ago

jwbensley commented 6 years ago

Hi there,

When I try to run your client I get the following stack dump

bensley@htpc-ubuntu:~$ slackadaisical
TypeError: Object.values is not a function
    at /home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/dist/ChannelsList.js:314:43
    at Request._callback (/home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/dist/SlackAPI.js:219:53)
    at Request.self.callback (/home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/node_modules/request/request.js:185:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/node_modules/request/request.js:1161:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/node_modules/request/request.js:1083:12)
    at IncomingMessage.g (events.js:292:16)

This is my info:

# I did the "Fast Install"
$ echo "XXXXX" | tee ~/.slack_token # see below

# Slack token exists
bensley@htpc-ubuntu:~$ ls -l .slack_token
-rw-rw-r-- 1 bensley bensley 74 Aug 23 10:08 .slack_token

$ npm install -g slackadaisical
bensley@htpc-ubuntu:~$ npm install -g slackadaisical
/home/bensley/.nvm/versions/node/v6.14.4/bin/slackadaisical -> /home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/dist/index.js

> websocket@1.0.26 install /home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/node_modules/websocket
> (node-gyp rebuild 2> builderror.log) || (exit 0)

make: Entering directory `/home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/node_modules/websocket/build'
  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
  SOLINK_MODULE(target) Release/obj.target/bufferutil.node
  COPY Release/bufferutil.node
  CXX(target) Release/obj.target/validation/src/validation.o
  SOLINK_MODULE(target) Release/obj.target/validation.node
  COPY Release/validation.node
make: Leaving directory `/home/bensley/.nvm/versions/node/v6.14.4/lib/node_modules/slackadaisical/node_modules/websocket/build'
/home/bensley/.nvm/versions/node/v6.14.4/lib
└─┬ slackadaisical@0.1.2
  ├── blessed@0.1.81
  ├── moment@2.22.2
  ├─┬ node-fetch@1.7.3
  │ ├─┬ encoding@0.1.12
  │ │ └─┬ iconv-lite@0.4.24
  │ │   └── safer-buffer@2.1.2
  │ └── is-stream@1.1.0
  ├─┬ request@2.88.0
  │ ├── aws-sign2@0.7.0
  │ ├── aws4@1.8.0
  │ ├── caseless@0.12.0
  │ ├─┬ combined-stream@1.0.6
  │ │ └── delayed-stream@1.0.0
  │ ├── extend@3.0.2
  │ ├── forever-agent@0.6.1
  │ ├─┬ form-data@2.3.2
  │ │ └── asynckit@0.4.0
  │ ├─┬ har-validator@5.1.0
  │ │ ├─┬ ajv@5.5.2
  │ │ │ ├── co@4.6.0
  │ │ │ ├── fast-deep-equal@1.1.0
  │ │ │ ├── fast-json-stable-stringify@2.0.0
  │ │ │ └── json-schema-traverse@0.3.1
  │ │ └── har-schema@2.0.0
  │ ├─┬ http-signature@1.2.0
  │ │ ├── assert-plus@1.0.0
  │ │ ├─┬ jsprim@1.4.1
  │ │ │ ├── extsprintf@1.3.0
  │ │ │ ├── json-schema@0.2.3
  │ │ │ └─┬ verror@1.10.0
  │ │ │   └── core-util-is@1.0.2
  │ │ └─┬ sshpk@1.14.2
  │ │   ├── asn1@0.2.4
  │ │   ├── bcrypt-pbkdf@1.0.2
  │ │   ├── dashdash@1.14.1
  │ │   ├── ecc-jsbn@0.1.2
  │ │   ├── getpass@0.1.7
  │ │   ├── jsbn@0.1.1
  │ │   └── tweetnacl@0.14.5
  │ ├── is-typedarray@1.0.0
  │ ├── isstream@0.1.2
  │ ├── json-stringify-safe@5.0.1
  │ ├─┬ mime-types@2.1.19
  │ │ └── mime-db@1.35.0
  │ ├── oauth-sign@0.9.0
  │ ├── performance-now@2.1.0
  │ ├── qs@6.5.2
  │ ├── safe-buffer@5.1.2
  │ ├─┬ tough-cookie@2.4.3
  │ │ ├── psl@1.1.29
  │ │ └── punycode@1.4.1
  │ ├── tunnel-agent@0.6.0
  │ └── uuid@3.3.2
  ├─┬ websocket@1.0.26
  │ ├─┬ debug@2.6.9
  │ │ └── ms@2.0.0
  │ ├── nan@2.10.0
  │ ├── typedarray-to-buffer@3.1.5
  │ └── yaeti@0.0.6
  └── word-wrap@1.2.3

bensley@htpc-ubuntu:~$ npm --version
3.10.10

bensley@htpc-ubuntu:~$ uname -a
Linux htpc-ubuntu 3.13.0-52-generic #86-Ubuntu SMP Mon May 4 04:32:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

bensley@htpc-ubuntu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty
jwbensley commented 6 years ago

Based on the info in this SO post I have upgraded my NodeJS to v7.10.1 and I can start the app now (sorry if this is basic info but I'm new to NodeJS):

https://stackoverflow.com/questions/40421825/how-to-use-object-values-on-server-side-in-node-js#40421941

Object.values is a new feature in ES2017. It is very bleeding edge. Node.js has full support for it from version 7.0.

6.8.1 supports it, but it is considered unstable and is locked behind the --harmony flag.

You can either:

Upgrade to the latest Node.js LTS and use --harmony
Upgrade to the latest Node.js Current
Use a polyfill
bensley@htpc-ubuntu:~$ nvm install 7.10.1
######################################################################## 100.0%
Checksums empty
Now using node v7.10.1 (npm v4.2.0)
bensley@htpc-ubuntu:~$ nvm use 7.10.1
Now using node v7.10.1 (npm v4.2.0)
bensley@htpc-ubuntu:~$ slackadaisical

I can start slackadaisical now but trying to select any room crashes:

TypeError: Cannot read property 'ts' of undefined
    at SlackAPI.markChannelRead (/usr/local/lib/node_modules/slackadaisical/dist/SlackAPI.js:137:76)
    at MessagesList.loadHistory (/usr/local/lib/node_modules/slackadaisical/dist/MessagesList.js:133:26)
    at /usr/local/lib/node_modules/slackadaisical/dist/MessagesList.js:87:23
    at Request._callback (/usr/local/lib/node_modules/slackadaisical/dist/SlackAPI.js:166:53)
    at Request.self.callback (/usr/local/lib/node_modules/slackadaisical/node_modules/request/request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/usr/local/lib/node_modules/slackadaisical/node_modules/request/request.js:1161:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
jwbensley commented 6 years ago

I've upgraded to the latest version available to me:

bensley@htpc-ubuntu:~$ nvm install 10.9.0
######################################################################## 100.0%
Checksums empty
Now using node v10.9.0 (npm v6.2.0)
bensley@htpc-ubuntu:~$ nvm use 10.9.0
Now using node v10.9.0 (npm v6.2.0)
bensley@htpc-ubuntu:~$ slackadaisical

I can join some channels but joining others still crasahes:

TypeError: Cannot read property 'ts' of undefined
    at SlackAPI.markChannelRead (/usr/local/lib/node_modules/slackadaisical/dist/SlackAPI.js:137:76)
    at MessagesList.loadHistory (/usr/local/lib/node_modules/slackadaisical/dist/MessagesList.js:133:26)
    at /usr/local/lib/node_modules/slackadaisical/dist/MessagesList.js:87:23
    at Request._callback (/usr/local/lib/node_modules/slackadaisical/dist/SlackAPI.js:166:53)
    at Request.self.callback (/usr/local/lib/node_modules/slackadaisical/node_modules/request/request.js:185:22)
    at Request.emit (events.js:182:13)
    at Request.<anonymous> (/usr/local/lib/node_modules/slackadaisical/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:182:13)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/slackadaisical/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:273:13)
tjcelaya commented 6 years ago

@jwbensley your latest error looks a lot like #15

My workaround was to select channels with ^L and Enter so you might want to try that.

Regarding the version issue (which anyone can stumble over even if they're not new to node) you could open a PR updating the README to call out the required node version and/or update package.json with "engines" and "engineStrict" properties.

(note: not a maintainer just a user)

jwbensley commented 6 years ago

Hi @tjcelaya - the solution to my problem was to log into Slack and change my "Mark as Read" settings.

Previously I had "Start me off where I left off, and mark the channel read" selected. I changed to "Start me at the newest message, but leave the unseen messages unread" and the issue stopped.

It seems the issue was that trying to change to a channel with unread messages, the Slackadaisical client would try to mark the channel/messages as read and crash as per my stack trace.

This has stopped now that I have changed the setting as per above.