Skip to content

Commit

Permalink
fix: avoid memoryleak in client-h1 (#3510) (#3672)
Browse files Browse the repository at this point in the history
(cherry picked from commit b725457)

Co-authored-by: Aras Abbasi <aras.abbasi@googlemail.com>
  • Loading branch information
github-actions[bot] and Uzlopak authored Oct 3, 2024
1 parent 52ae2f0 commit 7466672
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/dispatcher/client-h1.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Parser {
if (value !== this.timeoutValue) {
timers.clearTimeout(this.timeout)
if (value) {
this.timeout = timers.setTimeout(onParserTimeout, value, this)
this.timeout = timers.setTimeout(onParserTimeout, value, new WeakRef(this))
// istanbul ignore else: only for jest
if (this.timeout.unref) {
this.timeout.unref()
Expand Down Expand Up @@ -613,16 +613,16 @@ class Parser {
}

function onParserTimeout (parser) {
const { socket, timeoutType, client } = parser
const { socket, timeoutType, client, paused } = parser.deref()

/* istanbul ignore else */
if (timeoutType === TIMEOUT_HEADERS) {
if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
assert(!parser.paused, 'cannot be paused while waiting for headers')
assert(!paused, 'cannot be paused while waiting for headers')
util.destroy(socket, new HeadersTimeoutError())
}
} else if (timeoutType === TIMEOUT_BODY) {
if (!parser.paused) {
if (!paused) {
util.destroy(socket, new BodyTimeoutError())
}
} else if (timeoutType === TIMEOUT_IDLE) {
Expand Down

0 comments on commit 7466672

Please sign in to comment.