NicolasSiver / nodebb-plugin-ns-twitch-monitor

Monitors specific channels and adds them to widget view
MIT License
3 stars 5 forks source link

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

Closed Jutosa closed 8 years ago

Jutosa commented 8 years ago

Helllo,

I'm getting the following error that crashes my nodebb. (I can reset the plugin, though)

One of site admins might have entered some wrong setting but he isn't exactly sure what he did anymore.

Nodebb is running on Ubuntu 16.04 inside a Docker container, using MongoDB and nginx as a proxy.

I can give you more specific information if you tell me what you need to know.

5/6 12:26 [266] - info: [plugins/twitch-monitor] Start monitoring of channels, delay is 30000 ms
5/6 12:27 [266] - error: TypeError: Cannot read property 'name' of undefined
    at List.<anonymous> (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:126:44)
    at Array.forEach (native)
    at List.update (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:125:23)
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/streammanager.js:78:30
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:47:13
    at /usr/src/app/node_modules/async/lib/async.js:52:16
    at /usr/src/app/node_modules/async/lib/async.js:1209:30
    at Request._callback (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:40:21)
    at Request.self.callback (/usr/src/app/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:988:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at /usr/src/app/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
TypeError: Cannot read property 'name' of undefined
    at List.<anonymous> (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:126:44)
    at Array.forEach (native)
    at List.update (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:125:23)
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/streammanager.js:78:30
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:47:13
    at /usr/src/app/node_modules/async/lib/async.js:52:16
    at /usr/src/app/node_modules/async/lib/async.js:1209:30
    at Request._callback (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:40:21)
    at Request.self.callback (/usr/src/app/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:988:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at /usr/src/app/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)
NicolasSiver commented 8 years ago

Give a try for 3.0.1 version. Refactored a bit how references are managed.

Jutosa commented 8 years ago

Thank you for the quick response. I updated and how I get this error:

8/6 21:05 [867] - error: TypeError: Cannot read property 'cid' of undefined
    at List.findChannelIndexById (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:90:33)
    at List.setChannel (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:151:26)
    at List.<anonymous> (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:171:22)
    at Array.forEach (native)
    at List.update (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:167:23)
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/streammanager.js:93:30
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:47:13
    at /usr/src/app/node_modules/async/lib/async.js:52:16
    at /usr/src/app/node_modules/async/lib/async.js:1209:30
    at Request._callback (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:40:21)
    at Request.self.callback (/usr/src/app/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:988:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at /usr/src/app/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
    at nextTickCallbackWith2Args (node.js:442:9)
TypeError: Cannot read property 'cid' of undefined
    at List.findChannelIndexById (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:90:33)
    at List.setChannel (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:151:26)
    at List.<anonymous> (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:171:22)
    at Array.forEach (native)
    at List.update (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:167:23)
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/streammanager.js:93:30
    at /usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:47:13
    at /usr/src/app/node_modules/async/lib/async.js:52:16
    at /usr/src/app/node_modules/async/lib/async.js:1209:30
    at Request._callback (/usr/src/app/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:40:21)
    at Request.self.callback (/usr/src/app/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:988:12)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at /usr/src/app/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
    at nextTickCallbackWith2Args (node.js:442:9)

It causes nodebb to restart after a couple of seconds so it's hard for me to look for the cause. Do you have any ideas?

NicolasSiver commented 8 years ago

Yes, I have an overall idea, that something sets channel to the empty value. That is why in both cases, values aren't accessible.

  1. How many twitch channels do you have?
  2. How long it takes until error occurs?
  3. Do you see any behaviors just before error? Some channel goes Live, goes Offline, etc.
NicolasSiver commented 8 years ago

Give a try 3.0.2

Niller2005 commented 8 years ago
  1. 0
  2. 30 secs
  3. No. Nothing is happening. It's just when the plugin is installed

This is on 3.0.2

at List.<anonymous> (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:170:48)
    at Array.forEach (native)
    at List.update (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:169:23)
    at /var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/streammanager.js:93:30
    at /var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:47:13
    at /var/nodebb/node_modules/async/lib/async.js:52:16
    at /var/nodebb/node_modules/async/lib/async.js:1209:30
    at Request._callback (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:40:21)
    at Request.self.callback (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/node_modules/request/request.js:988:12)
    at emitNone (events.js:72:20)
TypeError: Cannot read property 'name' of undefined
    at List.<anonymous> (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:170:48)
    at Array.forEach (native)
    at List.update (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/model/streamlist.js:169:23)
    at /var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/streammanager.js:93:30
    at /var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:47:13
    at /var/nodebb/node_modules/async/lib/async.js:52:16
    at /var/nodebb/node_modules/async/lib/async.js:1209:30
    at Request._callback (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/plugin/twitch/api.js:40:21)
    at Request.self.callback (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/node_modules/request/request.js:200:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/node_modules/request/request.js:1067:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/var/nodebb/node_modules/nodebb-plugin-ns-twitch-monitor/node_modules/request/request.js:988:12)
    at emitNone (events.js:72:20)
NicolasSiver commented 8 years ago

@Niller2005 do you have this error in your logs, just after plugin installation?

Niller2005 commented 8 years ago

@NicolasSiver, yes

Niller2005 commented 8 years ago

i did a logger.log('error', this.channels); above the line that fails and it outputs this: error: [plugins/twitch-monitor] 0=undefined, 1=undefined, 2=undefined, 3=undefined, 4=undefined, 5=undefined, 6=undefined, 7=undefined, 8=undefined, 9=undefined, 10=undefined, 11=undefined, 12=undefined, 13=undefined, 14=undefined, 15=undefined, 16=undefined

NicolasSiver commented 8 years ago

Interesting. @Niller2005 how many channels do you have? 17?

NicolasSiver commented 8 years ago

Published 3.0.3, with several checks on undefined. It should give more insight: either It's a Database or Twitch API.

Niller2005 commented 8 years ago

getting error: [plugins/twitch-monitor] Stream initialization warning, detected "undefined" channel in the list now. But how do i clear the list, when i can't see anything in the acp?

NicolasSiver commented 8 years ago

@Niller2005 Do you use Redis or MongoDB?

Niller2005 commented 8 years ago

MongoDB

Niller2005 commented 8 years ago

And no, I don't have 17 channels, I think it's because I tried to add the same channel so many times when nothing happened.

NicolasSiver commented 8 years ago

If you are familiar with MongoDB, you could check, for the records in Database, via such request (when you will select your database via use)

getCollection('objects').find({_key:/twitch_monitor:channel$/})

It should return values, while db.getCollection('objects').find({_key:/twitch_monitor:channel:\d/}) should not return anything in your case (as you said you don't have any channels in the list now)

For now, I'm going to check if It's possible to have partial records in Database, like these ones.

Niller2005 commented 8 years ago

I just deleted all the undefined records in the database, and tried to add a new channel, and it did the same thing.

NicolasSiver commented 8 years ago

Yes, It will not work for now. Working on another patch version, which should address this ticket ;) Stay tuned.

Niller2005 commented 8 years ago

Okay :+1:

Niller2005 commented 8 years ago

Everything works fine after last update.

NicolasSiver commented 8 years ago

Closing the ticket. Don't hesitate to provide an update if issue is still around.