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 for PlayModel #8

Closed
thedark1337 opened this issue Nov 30, 2015 · 9 comments
Closed

TypeError for PlayModel #8

thedark1337 opened this issue Nov 30, 2015 · 9 comments

Comments

@thedark1337
Copy link
Contributor

TypeError: Cannot read property '_id' of undefined
    at new PlayModel (/var/plug/charlotte/node_modules/dubapi/lib/models/playModel.js:6:19)
    at Object.callback (/var/plug/charlotte/node_modules/dubapi/lib/actionHandler.js:71:23)
    at Request.<anonymous> (/var/plug/charlotte/node_modules/dubapi/lib/requestHandler.js:109:65)
    at emitTwo (events.js:92:20)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (/var/plug/charlotte/node_modules/request/request.js:1035:10)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (/var/plug/charlotte/node_modules/request/request.js:962:12)
    at emitNone (events.js:72:20)

Not sure how this happened but I got this quite a bit earlier. Seems there needs to be a check if the _id exists or not 👍

@anjanms
Copy link
Owner

anjanms commented Nov 30, 2015

Has this happened more than once? And was it while connecting to a room?

If this is a reoccurring error I'll certainly add a check for it.

@thedark1337
Copy link
Contributor Author

I'll keep an eye on it but I think it did appear to happen when logging in. EDIT: Just happened again on advance. When the bot auto restarted it kept throwing that stacktrace as well

@thedark1337
Copy link
Contributor Author

@anjanms it happens when reordering the waitlist it seems http://prntscr.com/98xq8r EDIT: that's a different stacktrace than the one that occured for playMedia, seems somehow the _id's get undefined for these 2

@anjanms
Copy link
Owner

anjanms commented Dec 1, 2015

I've added checks that should prevent the errors. Please give v1.0.2 a try and let me know.

The Dubtrack API does some strange things at times. In this case it's not that the _ids themselves are null/undefined, but what it's trying to read them from is.

@thedark1337
Copy link
Contributor Author

Thanks, I'll let you know. That is very strange behavior indeed...

@BenWildeman
Copy link

I dunno if this is part of the same issue, but I've just checked my logs for the bot on my openshift account and I have a similar error, but for username (taken from the chat event data.user.username)

TypeError: Cannot read property 'username' of undefined
    at DubAPI.<anonymous> (/var/lib/openshift/565def4a0c1e66523e00011c/app-root/runtime/repo/bot/index.js:170:23)
    at DubAPI.emit (events.js:95:17)
    at DubAPI.EventHandler (/var/lib/openshift/565def4a0c1e66523e00011c/app-root/runtime/repo/node_modules/dubapi/lib/eventHandler.js:201:10)
    at Object.<anonymous> (/var/lib/openshift/565def4a0c1e66523e00011c/app-root/runtime/repo/node_modules/dubapi/node_modules/pubnub/node.js/pubnub.js:1536:47)
    at each (/var/lib/openshift/565def4a0c1e66523e00011c/app-root/runtime/repo/node_modules/dubapi/node_modules/pubnub/node.js/pubnub.js:148:15)
    at _connect.xdr.success (/var/lib/openshift/565def4a0c1e66523e00011c/app-root/runtime/repo/node_modules/dubapi/node_modules/pubnub/node.js/pubnub.js:1532:25)
    at finished (/var/lib/openshift/565def4a0c1e66523e00011c/app-root/runtime/repo/node_modules/dubapi/node_modules/pubnub/node.js/pubnub.js:2183:13)
    at IncomingMessage.<anonymous> (/var/lib/openshift/565def4a0c1e66523e00011c/app-root/runtime/repo/node_modules/dubapi/node_modules/pubnub/node.js/pubnub.js:2257:17)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16

it occurred twice in less that 24 hours (I don't have time stamps for them)

@BenWildeman
Copy link

just checked my jenkins build logs, it's using dubapi@1.0.2

@thedark1337
Copy link
Contributor Author

@anjanms The original issue i was reporting seems to be fixed for now. The one @NiTrOGhost is reporting i have not seen yet though and is a different issue, then again on my chat listener event i ignore if typeof data.user !== 'object' 😛

@anjanms
Copy link
Owner

anjanms commented Dec 3, 2015

@thedark1337 Awesome.

@NiTrOGhost That can happen if the user that sent the message is not in the internal users array. Usually when that happens the user isn't in the room server-side either.

I would recommend doing a typeof or undefined check on the user property before trying to access anything on it. If you want to handle the case of an undefined user you can access the raw event from Dubtrack through the raw property.

For instance, our bot will suggest that an undefined user refresh if they attempted to trigger a command.

@anjanms anjanms closed this as completed Dec 3, 2015
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