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

refactor: avoid http2 dynamic dispatch in socket handlers #2839

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: separate writeH1 and writeH2
  • Loading branch information
ronag committed Feb 25, 2024
commit b23d1f7bb5d94ccd85c15d5cdd53221dc01ebadb
12 changes: 9 additions & 3 deletions lib/dispatcher/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1399,10 +1399,15 @@ function shouldSendContentLength (method) {

function write (client, request) {
if (client[kHTTPConnVersion] === 'h2') {
writeH2(client, client[kHTTP2Session], request)
return
// TODO (fix): Why does this not return the value
// from writeH2.
writeH2(client, request)
Copy link
Member Author

Choose a reason for hiding this comment

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

@metcoder95 This is confusing to me. Seems to have been broken for a while.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it seems its kind of flaky there; once wrap with the interceptors I'll jump right away into H2

} else {
return writeH1(client, request)
}
}

function writeH1 (client, request) {
const { method, path, host, upgrade, blocking, reset } = request

let { body, headers, contentLength } = request
Expand Down Expand Up @@ -1580,7 +1585,8 @@ function write (client, request) {
return true
}

function writeH2 (client, session, request) {
function writeH2 (client, request) {
const session = client[kHTTP2Session]
const { body, method, path, host, upgrade, expectContinue, signal, headers: reqHeaders } = request

let headers
Expand Down
Loading