Skip to content

Commit

Permalink
fix: make pipelining limit work for h2
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Feb 28, 2024
1 parent 861f782 commit 5ad15a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/dispatcher/client-h1.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ class Parser {
// have been queued since then.
util.destroy(socket, new InformationalError('reset'))
return constants.ERROR.PAUSED
} else if (client[kPipelining] === 1) {
} else if (client[kPipelining] == null || client[kPipelining] === 1) {
// We must wait a full event loop cycle to reuse this socket to make sure
// that non-spec compliant servers are not closing the connection even if they
// said they won't.
Expand Down
12 changes: 7 additions & 5 deletions lib/dispatcher/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ const connectH2 = require('./client-h2.js')

const kClosedResolve = Symbol('kClosedResolve')

function getPipelining (client) {
return client[kPipelining] ?? (client[kHTTPContext]?.version === 'h2' ? Infinity : 1)
}

/**
* @type {import('../../types/client.js').default}
*/
Expand Down Expand Up @@ -280,7 +284,7 @@ class Client extends DispatcherBase {
const socket = this[kSocket]
return (
(socket && (socket[kReset] || socket[kWriting] || socket[kBlocking])) ||
(this[kSize] >= (this[kPipelining] || 1)) ||
(this[kSize] >= (getPipelining(this) || 1)) ||
this[kPending] > 0
)
}
Expand Down Expand Up @@ -564,10 +568,8 @@ function _resume (client, sync) {
return
}

if (client[kHTTPContext]?.version === 'h1') {
if (client[kRunning] >= (client[kPipelining] || 1)) {
return
}
if (client[kRunning] >= (getPipelining(client) || 1)) {
return
}

const request = client[kQueue][client[kPendingIdx]]
Expand Down

0 comments on commit 5ad15a9

Please sign in to comment.