Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 31dbabc

Browse files
pgtedaviddias
authored andcommitted
fix: added backpressure to the add stream (#810)
* fix: added backpressure to the add stream
1 parent 74b2b70 commit 31dbabc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/core/components/files.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,15 @@ class AddStreamDuplex extends Duplex {
184184
super(Object.assign({ objectMode: true }, options))
185185
this._pullStream = pullStream
186186
this._pushable = push
187+
this._waitingPullFlush = []
187188
}
188189

189190
_read () {
190191
this._pullStream(null, (end, data) => {
192+
while (this._waitingPullFlush.length) {
193+
const cb = this._waitingPullFlush.shift()
194+
cb()
195+
}
191196
if (end) {
192197
if (end instanceof Error) {
193198
this.emit('error', end)
@@ -199,7 +204,7 @@ class AddStreamDuplex extends Duplex {
199204
}
200205

201206
_write (chunk, encoding, callback) {
207+
this._waitingPullFlush.push(callback)
202208
this._pushable.push(chunk)
203-
callback()
204209
}
205210
}

0 commit comments

Comments
 (0)