From b4e7ab244367e94593788d7c158f66d0c4c69063 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Fri, 18 Dec 2015 19:20:57 -0800 Subject: [PATCH] Don't save a channel if it hasn't loaded yet --- src/channel/channel.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/channel/channel.js b/src/channel/channel.js index bde111e6..6c90c77a 100644 --- a/src/channel/channel.js +++ b/src/channel/channel.js @@ -178,6 +178,7 @@ Channel.prototype.loadState = function () { this.uniqueName); } }); + this.setFlag(Flags.C_READY); }).catch(ChannelStateSizeError, err => { const message = "This channel's state size has exceeded the memory limit " + @@ -207,6 +208,9 @@ Channel.prototype.loadState = function () { Channel.prototype.saveState = function () { if (!this.is(Flags.C_REGISTERED)) { return Promise.resolve(); + } else if (!this.is(Flags.C_READY)) { + return Promise.reject(new Error(`Attempted to save channel ${this.name} ` + + `but it wasn't finished loading yet!`)); } if (this.is(Flags.C_ERROR)) {