Skip to content

Commit

Permalink
fix: Client.stream writableNeedDrain
Browse files Browse the repository at this point in the history
Fixes: #441
  • Loading branch information
ronag committed Sep 25, 2020
1 parent 4208071 commit f4928d4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/client-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ class StreamHandler extends AsyncResource {
})

this.res = res

const needDrain = res.writableNeedDrain !== undefined
? res.writableNeedDrain
: res._writableState && res._writableState.needDrain

return needDrain
}

onData (chunk) {
Expand Down
4 changes: 3 additions & 1 deletion lib/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ class Parser extends HTTPParser {
}

try {
request.onHeaders(statusCode, headers, statusCode < 200 ? null : socket[kResume])
if (request.onHeaders(statusCode, headers, statusCode < 200 ? null : socket[kResume]) === false) {
socket[kPause]()
}
} catch (err) {
util.destroy(socket, err)
return 1
Expand Down
2 changes: 1 addition & 1 deletion lib/core/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Request {

clearRequestTimeout(this)

this[kHandler].onHeaders(statusCode, headers, resume)
return this[kHandler].onHeaders(statusCode, headers, resume)
}

onBody (chunk, offset, length) {
Expand Down

0 comments on commit f4928d4

Please sign in to comment.