@@ -169,7 +169,7 @@ class Parser {
169
169
if ( value !== this . timeoutValue ) {
170
170
timers . clearTimeout ( this . timeout )
171
171
if ( value ) {
172
- this . timeout = timers . setTimeout ( onParserTimeout , value , this )
172
+ this . timeout = timers . setTimeout ( onParserTimeout , value , new WeakRef ( this ) )
173
173
// istanbul ignore else: only for jest
174
174
if ( this . timeout . unref ) {
175
175
this . timeout . unref ( )
@@ -613,16 +613,16 @@ class Parser {
613
613
}
614
614
615
615
function onParserTimeout ( parser ) {
616
- const { socket, timeoutType, client } = parser
616
+ const { socket, timeoutType, client, paused } = parser . deref ( )
617
617
618
618
/* istanbul ignore else */
619
619
if ( timeoutType === TIMEOUT_HEADERS ) {
620
620
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' )
622
622
util . destroy ( socket , new HeadersTimeoutError ( ) )
623
623
}
624
624
} else if ( timeoutType === TIMEOUT_BODY ) {
625
- if ( ! parser . paused ) {
625
+ if ( ! paused ) {
626
626
util . destroy ( socket , new BodyTimeoutError ( ) )
627
627
}
628
628
} else if ( timeoutType === TIMEOUT_IDLE ) {
0 commit comments