Skip to content

Commit

Permalink
fix: proxy request hasError
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Sep 12, 2017
1 parent 86e0512 commit 70ffff0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,19 @@ function impl (req, resOrSocket, headOrNil, {
function proxy (req, resOrSocket, options, onRes, onError) {
const proxyReq = http.request(options)

let hasError = false

const abort = () => {
if (!proxyReq.aborted) {
proxyReq.abort()
}
}

const callback = err => {
if (hasError) {
return
}
hasError = true
req.removeListener('close', abort)
abort()
onError(err)
Expand Down

0 comments on commit 70ffff0

Please sign in to comment.