Skip to content
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(H2 Client): bind stream 'data' listener only after received 'response' event #2985

Merged
merged 6 commits into from
Mar 25, 2024
12 changes: 6 additions & 6 deletions lib/dispatcher/client-h2.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ function writeH2 (client, request) {
if (request.onHeaders(Number(statusCode), realHeaders, stream.resume.bind(stream), '') === false) {
stream.pause()
}

stream.on('data', (chunk) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add the link to the issue as comment?

if (request.onData(chunk) === false) {
stream.pause()
}
})
})

stream.once('end', () => {
Expand All @@ -418,12 +424,6 @@ function writeH2 (client, request) {
util.destroy(stream, err)
})

stream.on('data', (chunk) => {
if (request.onData(chunk) === false) {
stream.pause()
}
})

stream.once('close', () => {
session[kOpenStreams] -= 1
// TODO(HTTP/2): unref only if current streams count is 0
Expand Down
Loading