Don't save a channel if it hasn't loaded yet

This commit is contained in:
calzoneman 2015-12-18 19:20:57 -08:00
parent 176d4cb06f
commit b4e7ab2443
1 changed files with 4 additions and 0 deletions

View File

@ -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)) {