-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
http request 'end' event not fired #21398
Comments
@gonenduk there was a change around the semantics, yes. See the following section of the Streams documentation: https://nodejs.org/dist/latest-v10.x/docs/api/stream.html#stream_event_readable |
ping @mcollina — is this currently working fully as intended? |
Do we have a document with the changes in version 10 about this? |
I have very limited connectivity this week. I can have a look next week.
Cc @mafintosh - can you have a look
Il giorno mer 20 giu 2018 alle 05:05 Anatoli Papirovski <
[email protected]> ha scritto:
… ping @mcollina <https://github.com/mcollina> — is this currently working
fully as intended?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#21398 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADL45Y6Mjp1H39PE-ZMWFeN-itPuhC-ks5t-dgegaJpZM4Us7q9>
.
|
any updates? |
similar issue is opened from my lib. http is called const req = protocol.request(url, (res) => {
res.once('readable', () => {
onTransfer = Date.now();
});
res.on('data', (chunk) => {
body += chunk;
});
res.on('end', () => {
onTotal = Date.now();
res.body = body;
resolve({
url: url,
response: res,
time: {
begin: begin,
onLookup: onLookup,
onConnect: onConnect,
onSecureConnect: onSecureConnect,
onTransfer: onTransfer,
onTotal: onTotal,
}
});
});
}); |
I think there is a bug when using both |
But why is the end event not fired with node 10 and was always fired with 8 and below? |
@gonenduk until the bug is fixed, if you need it to work you can put listener on data event inside 'readable' event: res.once('readable', () => {
eventTimes.firstByteAt = process.hrtime()
res.on('data', (chunk) => { responseBody += chunk })
}) This seems to work fine. |
Thanks! The end event is fired! |
When there is at least one 'data' listener try to flow when last 'readable' listener gets removed and the stream is not piped. Currently if we have both 'readable' and 'data' listeners set only 'readable' listener will get called and stream will be stalled without 'data' and 'end' events if 'readable' listener neither read()'s nor resume()'s the stream. Fixes: nodejs#21398
Fixed in 98cf84f |
Fixes: #21398 See: #21696 PR-URL: #22209 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mathias Buus <[email protected]>
Fixes: #21398 See: #21696 PR-URL: #22209 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Mathias Buus <[email protected]>
Hi,
I am using the http request and breakdown the response times using events emitted at different stages of the request/response process.
With node < 10 it used to work well. With node >= 10 it has stopped working. The on end event of the response is not called. If I remove the readable event - then it is called.
Here is a sample code of rising stack on this subject (measuring http timings). Their sample also works on node < 10 but has the same problem with node >= 10:
Rising Stack sample code
Was anything changed in the way http calls are made in version 10?
The text was updated successfully, but these errors were encountered: