Skip to content

Commit c84d7d4

Browse files
Uzlopakgithub-actions[bot]
authored andcommitted
fix: avoid memoryleak in client-h1 (#3510)
(cherry picked from commit b725457)
1 parent 52ae2f0 commit c84d7d4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/dispatcher/client-h1.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class Parser {
169169
if (value !== this.timeoutValue) {
170170
timers.clearTimeout(this.timeout)
171171
if (value) {
172-
this.timeout = timers.setTimeout(onParserTimeout, value, this)
172+
this.timeout = timers.setTimeout(onParserTimeout, value, new WeakRef(this))
173173
// istanbul ignore else: only for jest
174174
if (this.timeout.unref) {
175175
this.timeout.unref()
@@ -613,16 +613,16 @@ class Parser {
613613
}
614614

615615
function onParserTimeout (parser) {
616-
const { socket, timeoutType, client } = parser
616+
const { socket, timeoutType, client, paused } = parser.deref()
617617

618618
/* istanbul ignore else */
619619
if (timeoutType === TIMEOUT_HEADERS) {
620620
if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) {
621-
assert(!parser.paused, 'cannot be paused while waiting for headers')
621+
assert(!paused, 'cannot be paused while waiting for headers')
622622
util.destroy(socket, new HeadersTimeoutError())
623623
}
624624
} else if (timeoutType === TIMEOUT_BODY) {
625-
if (!parser.paused) {
625+
if (!paused) {
626626
util.destroy(socket, new BodyTimeoutError())
627627
}
628628
} else if (timeoutType === TIMEOUT_IDLE) {

0 commit comments

Comments
 (0)