Skip to content

Commit 6d92f14

Browse files
committed
fix: free parser when detaching
1 parent 8bf521e commit 6d92f14

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/core/client.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,11 @@ class Parser extends HTTPParser {
651651
resume(client)
652652
}
653653
}
654+
655+
destroy () {
656+
this.unconsume()
657+
setImmediate((self) => self.close(), this)
658+
}
654659
}
655660

656661
function onSocketConnect () {
@@ -705,8 +710,7 @@ function onSocketClose () {
705710

706711
client[kSocket] = null
707712

708-
parser.unconsume()
709-
setImmediate(() => parser.close())
713+
parser.destroy()
710714

711715
if (err.code !== 'UND_ERR_INFO') {
712716
// Evict session on errors.
@@ -744,10 +748,11 @@ function onSocketSession (session) {
744748
}
745749

746750
function detachSocket (socket) {
751+
socket[kParser].destroy()
752+
socket[kParser] = null
747753
socket[kPause] = null
748754
socket[kResume] = null
749755
socket[kClient] = null
750-
socket[kParser] = null
751756
socket[kError] = null
752757
socket
753758
.removeListener('timeout', onSocketTimeout)

0 commit comments

Comments
 (0)