Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 7403afc

Browse files
committedNov 20, 2017
only do file backpressure on node because browser HTTP
1 parent 6583fcf commit 7403afc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed
 

‎src/utils/multipart.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

33
const Transform = require('stream').Transform
4+
const isNode = require('detect-node')
45

56
const PADDING = '--'
67
const NEW_LINE = '\r\n'
@@ -91,7 +92,11 @@ class Multipart extends Transform {
9192

9293
content.on('data', (data) => {
9394
const drained = this.push(data)
94-
if (!drained) {
95+
// Only do the drain dance on Node.js.
96+
// In browserland, the underlying stream
97+
// does NOT drain because the request is only sent
98+
// once this stream ends.
99+
if (!drained && isNode) {
95100
content.pause()
96101
this.once('drain', () => content.resume())
97102
}

0 commit comments

Comments
 (0)