Skip to content

Commit

Permalink
fix: free parser when detaching
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Oct 25, 2020
1 parent e0f33a8 commit 1dc8328
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,11 @@ class Parser extends HTTPParser {
resume(client)
}
}

destroy () {
this.unconsume()
setImmediate((self) => self.close(), this)
}
}

function onSocketConnect () {
Expand Down Expand Up @@ -705,8 +710,7 @@ function onSocketClose () {

client[kSocket] = null

parser.unconsume()
setImmediate(() => parser.close())
parser.destroy()

if (err.code !== 'UND_ERR_INFO') {
// Evict session on errors.
Expand Down Expand Up @@ -744,10 +748,11 @@ function onSocketSession (session) {
}

function detachSocket (socket) {
socket[kParser].destroy()
socket[kParser] = null
socket[kPause] = null
socket[kResume] = null
socket[kClient] = null
socket[kParser] = null
socket[kError] = null
socket
.removeListener('timeout', onSocketTimeout)
Expand Down

0 comments on commit 1dc8328

Please sign in to comment.