New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(HttpClient): turn res stream to readable in HttpClient #175
Conversation
lib/HttpClient.js
Outdated
@@ -188,6 +188,8 @@ function rawRequest(opts, cb) { | |||
|
|||
var requestTime = new Date().getTime(); | |||
req = proto.request(opts, function onResponse(res) { | |||
res.resume(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on why this is needed?
Great catch @hekike! To give a bit more details: it seems the regression was introduced by nodejs/node@cf5f986, which effectively makes adding a That change was released with Node.js v10.0.0. Before that change, adding a Long term, ideally we would not mix both streaming modes if possible, and we would use |
lib/HttpClient.js
Outdated
@@ -223,6 +219,11 @@ function rawRequest(opts, cb) { | |||
}); | |||
|
|||
emitResult((err || null), req, res); | |||
|
|||
// This has to be after res.on('data') in Node >= v10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: It could be useful to add a bit more info about why that is necessary (maybe add the link to the PR in the nodejs repo?).
My apologies, it is listed, since all major changes are listed in the changelog (look for |
Turn res stream readable immediately to make it possible to consume later in inherited clients.