Skip to content

Commit

Permalink
fix: don't queue if destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Feb 27, 2021
1 parent 68356f3 commit 3d002c1
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions lib/core/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,17 +628,17 @@ class Parser extends HTTPParser {
}

[HTTPParser.kOnBody] (chunk, offset, length) {
if (this.paused) {
this.queue.push([HTTPParser.kOnBody, chunk, offset, length])
return
}

const { socket, statusCode, request, timeout } = this

if (socket.destroyed) {
return
}

if (this.paused) {
this.queue.push([HTTPParser.kOnBody, chunk, offset, length])
return
}

if (timeout && timeout.refresh) {
timeout.refresh()
}
Expand All @@ -655,18 +655,17 @@ class Parser extends HTTPParser {
}

[HTTPParser.kOnMessageComplete] () {
/* istanbul ignore next: difficult to make a test case for */
if (this.paused) {
this.queue.push([HTTPParser.kOnMessageComplete])
return
}

const { client, socket, statusCode, headers, upgrade, request, trailers } = this

if (socket.destroyed) {
return
}

if (this.paused) {
this.queue.push([HTTPParser.kOnMessageComplete])
return
}

assert(statusCode >= 100)
assert(this.resuming || (socket._handle && socket._handle.reading))

Expand Down

0 comments on commit 3d002c1

Please sign in to comment.