diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index 60af7f580..49edd8b13 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -155,6 +155,11 @@ module.exports = class File extends TransportStream { debug('logged %s %s', this._size, output); this.emit('logged', info); + // Do not attempt to rotate files while rotating + if (this._rotate) { + return; + } + // Do not attempt to rotate files while opening if (this._opening) { return; @@ -502,6 +507,7 @@ module.exports = class File extends TransportStream { */ _cleanupStream(stream) { stream.removeListener('error', this._onError); + stream.destroy(); return stream; }