diff --git a/src/core/components/files.js b/src/core/components/files.js index 3c371da981..b84cff3fef 100644 --- a/src/core/components/files.js +++ b/src/core/components/files.js @@ -184,10 +184,15 @@ class AddStreamDuplex extends Duplex { super(Object.assign({ objectMode: true }, options)) this._pullStream = pullStream this._pushable = push + this._waitingPullFlush = [] } _read () { this._pullStream(null, (end, data) => { + while (this._waitingPullFlush.length) { + const cb = this._waitingPullFlush.shift() + cb() + } if (end) { if (end instanceof Error) { this.emit('error', end) @@ -199,7 +204,7 @@ class AddStreamDuplex extends Duplex { } _write (chunk, encoding, callback) { + this._waitingPullFlush.push(callback) this._pushable.push(chunk) - callback() } }