Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Object [object Object] has no method 'filter' #201

Closed
martindale opened this issue Jun 14, 2016 · 5 comments
Closed

TypeError: Object [object Object] has no method 'filter' #201

martindale opened this issue Jun 14, 2016 · 5 comments

Comments

@martindale
Copy link

Seems like the users array isn't always created.

/home/eric/slackin/node/slack.js:96
        users = users.filter(function (x) {
                      ^
TypeError: Object [object Object] has no method 'filter'
    at SlackData.onres (/home/eric/slackin/node/slack.js:96:23)
    at /home/eric/slackin/node/slack.js:61:17
    at Request.callback (/home/eric/slackin/node_modules/superagent/lib/node/index.js:746:30)
    at Request.<anonymous> (/home/eric/slackin/node_modules/superagent/lib/node/index.js:135:10)
    at Request.emit (events.js:95:17)
    at Stream.<anonymous> (/home/eric/slackin/node_modules/superagent/lib/node/index.js:938:12)
    at Stream.emit (events.js:117:20)
    at Unzip.<anonymous> (/home/eric/slackin/node_modules/superagent/lib/node/utils.js:124:12)
    at Unzip.emit (events.js:117:20)
    at _stream_readable.js:944:16
@josenicomaia
Copy link

I got the same problem.

image

@jordanh
Copy link
Contributor

jordanh commented Aug 12, 2016

Ditto that:

image

@jordanh
Copy link
Contributor

jordanh commented Aug 12, 2016

Interesting. It looks like the only way this could happen is if something subtly goes wrong with the slack API call:

fetch (){

The method onres is already fairly defensive. It checks for bad HTTP status. I am going to add a check to make sure the users array is set and see if it still fails:

    if (!users || (users && !users.length)) {
      let err = new Error(`Invalid Slack response: ${res.status}`)
      this.emit('error', err)
      return this.retry()
    }

jordanh added a commit to ParabolInc/slackin that referenced this issue Aug 12, 2016
@jordanh
Copy link
Contributor

jordanh commented Aug 12, 2016

Created a branch here to experiment: https://github.com/ParabolInc/slackin/tree/fetch-users-defense-%23201

@jordanh
Copy link
Contributor

jordanh commented Aug 26, 2016

After 2 weeks, our Slackin instance hasn't crashed. According to our devops logs, that's a new record. I think we squashed this one. I'll submit a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants