Skip to content

Commit 70ffff0

Browse files
committed
fix: proxy request hasError
1 parent 86e0512 commit 70ffff0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,19 @@ function impl (req, resOrSocket, headOrNil, {
143143
function proxy (req, resOrSocket, options, onRes, onError) {
144144
const proxyReq = http.request(options)
145145

146+
let hasError = false
147+
146148
const abort = () => {
147149
if (!proxyReq.aborted) {
148150
proxyReq.abort()
149151
}
150152
}
151153

152154
const callback = err => {
155+
if (hasError) {
156+
return
157+
}
158+
hasError = true
153159
req.removeListener('close', abort)
154160
abort()
155161
onError(err)

0 commit comments

Comments
 (0)