diff --git a/lib/channel.js b/lib/channel.js index ec3c2914..46884dce 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -466,6 +466,14 @@ Channel.prototype.getIPRank = function (ip, callback) { */ Channel.prototype.preJoin = function (user, password) { var self = this; + + // Allow channel to unload if the only user disconnects without finishing a join + user.socket.on("disconnect", function () { + if (!user.inChannel() && self.users.length === 0) { + self.emit("empty"); + } + }); + self.whenReady(function () { if (self.dead) { return;