diff --git a/lib/handlers/rotating.js b/lib/handlers/rotating.js index ea90b75..4d7510c 100644 --- a/lib/handlers/rotating.js +++ b/lib/handlers/rotating.js @@ -50,6 +50,8 @@ RotatingFileHandler.prototype._write = function write() { if (this._buffer.length) { var tuple = this._buffer.shift(); this._withSize(tuple[0], tuple[1]); + } else { + this._writing = false; } }; diff --git a/test/handlers.js b/test/handlers.js index 71f88c5..c2ccba8 100644 --- a/test/handlers.js +++ b/test/handlers.js @@ -261,6 +261,21 @@ module.exports = { assert.equal(fs.statSync(filename + '.2').size, 56); assert(!fs.existsSync(filename + '.3')); }).done(done); + }, + 'should continue to write after buffer is flushed': function(done) { + this.timeout(5000); + + var filename = tmp(); + var handler = new intel.handlers.Rotating({ + file: filename, + maxSize: 64 + }); + + handler.handle({ message: bytes(29) }).then(function(){ + return handler.handle({ message: bytes(31) }); + }).then(function(){ + assert.equal(fs.statSync(filename).size, 62); + }).done(done); } } }