Add check for weird setAFK edge case

This commit is contained in:
Calvin Montgomery 2017-12-11 22:46:41 -08:00
parent 1e969117c4
commit 29be9233e9
2 changed files with 16 additions and 1 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.51.9",
"version": "3.51.10",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -242,6 +242,21 @@ User.prototype.setAFK = function (afk) {
this.autoAFK();
}
if (!this.inChannel()) {
// I haven't exactly nailed down why this.channel can
// become null halfway through the function, but based
// on log analysis I suspect it's because this.socket.emit()
// can fire the "disconnect" event which then tears down
// the User object.
LOGGER.warn(
"Encountered this.channel == null from setAFK. " +
"this.dead=%t this.flags=%b",
this.dead,
this.flags
);
return;
}
/* Number of AFK users changed, voteskip state changes */
if (this.channel.modules.voteskip) {
this.channel.modules.voteskip.update();