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

Commit

Permalink
only do file backpressure on node because browser HTTP
Browse files Browse the repository at this point in the history
  • Loading branch information
pgte committed Nov 20, 2017
1 parent 6583fcf commit 7403afc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/utils/multipart.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const Transform = require('stream').Transform
const isNode = require('detect-node')

const PADDING = '--'
const NEW_LINE = '\r\n'
Expand Down Expand Up @@ -91,7 +92,11 @@ class Multipart extends Transform {

content.on('data', (data) => {
const drained = this.push(data)
if (!drained) {
// Only do the drain dance on Node.js.
// In browserland, the underlying stream
// does NOT drain because the request is only sent
// once this stream ends.
if (!drained && isNode) {
content.pause()
this.once('drain', () => content.resume())
}
Expand Down

0 comments on commit 7403afc

Please sign in to comment.