diff --git a/lib/winston/transports/file.js b/lib/winston/transports/file.js index 47bbee56f..6797580ad 100644 --- a/lib/winston/transports/file.js +++ b/lib/winston/transports/file.js @@ -441,6 +441,11 @@ File.prototype._createStream = function () { // and thus can emit the `open` event. // self.once('flush', function () { + // Because "flush" event is based on native stream "drain" event, + // logs could be written inbetween "self.flush()" and here + // Therefore, we need to flush again to make sure everything is flushed + self.flush(); + self.opening = false; self.emit('open', fullname); });