diff --git a/lib/bunyan.js b/lib/bunyan.js index 18632dd..8461118 100644 --- a/lib/bunyan.js +++ b/lib/bunyan.js @@ -1082,9 +1082,13 @@ util.inherits(RotatingFileStream, EventEmitter); RotatingFileStream.prototype._setupNextRot = function () { var self = this; this.rotAt = this._nextRotTime(); + var delay = this.rotAt - Date.now(); + if (delay > 2147483647) { + delay = 2147483647; + } this.timeout = setTimeout( function () { self.rotate(); }, - this.rotAt - Date.now()); + delay); if (typeof (this.timeout.unref) === 'function') { this.timeout.unref(); } @@ -1175,6 +1179,10 @@ RotatingFileStream.prototype.rotate = function rotate() { var self = this; var _DEBUG = false; + if (self.rotAt && self.rotAt > Date.now()) { + return self._setupNextRot(); + } + if (_DEBUG) { console.log('-- [%s, pid=%s] rotating %s', new Date(), process.pid, self.path);