Skip to content

Commit

Permalink
refactor: parser.destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Oct 26, 2020
1 parent ce104eb commit 67fde56
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions lib/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,13 @@ class Parser extends HTTPParser {
}

if (!socket.destroyed && !request.aborted) {
this.destroy()

clearTimeout(socket[kIdleTimeout])
socket[kIdleTimeout] = null
socket[kIdleTimeoutValue] = null

setImmediate((self) => self.close(), socket[kParser])
socket[kParser] = null

socket[kPause] = null
socket[kResume] = null
socket[kClient] = null
Expand Down Expand Up @@ -639,11 +640,6 @@ class Parser extends HTTPParser {
resume(client)
}
}

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

function onSocketConnect () {
Expand Down Expand Up @@ -692,7 +688,8 @@ function onSocketClose () {

client[kSocket] = null

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

if (err.code !== 'UND_ERR_INFO') {
// Evict session on errors.
Expand Down

0 comments on commit 67fde56

Please sign in to comment.