Skip to content

Commit

Permalink
Fix sending streams on Node 10
Browse files Browse the repository at this point in the history
  • Loading branch information
nwoltman committed May 1, 2018
1 parent b9d464f commit 5042497
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Response.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,12 @@ function sendFinalPayload(res, payload) {
}

function sendStream(payload, resStream, res) {
var sourceOpen = true
var payloadOpen = true
var resOpen = true

eos(payload, {readable: true, writable: false}, (err) => {
sourceOpen = false
if (!err) {
payloadOpen = false
if (!err || !resOpen) {
return
}

Expand All @@ -279,7 +280,8 @@ function sendStream(payload, resStream, res) {
})

eos(resStream, (err) => {
if (err && sourceOpen) {
resOpen = false
if (err && payloadOpen) {
res.route.onStreamError(err)
destroyStream(payload)
}
Expand Down

0 comments on commit 5042497

Please sign in to comment.