Skip to content

Commit a4070be

Browse files
committed
fix: handle res error in outside scope
1 parent c99a086 commit a4070be

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function impl (req, resOrSocket, headOrNil, {
125125

126126
// NOTE http2.Http2ServerRequest doesn't forward stream errors.
127127
(req.stream || req).on('error', onError)
128+
resOrSocket.on('error', onError)
128129

129130
return proxy(req, resOrSocket, options, onRes, onError)
130131
} catch (err) {
@@ -202,7 +203,6 @@ function proxy (req, resOrSocket, options, onRes, onError) {
202203
proxyRes
203204
.on('error', callback)
204205
.pipe(resOrSocket)
205-
.on('error', callback)
206206
}
207207
} catch (err) {
208208
callback(err)
@@ -241,7 +241,6 @@ function proxy (req, resOrSocket, options, onRes, onError) {
241241
proxySocket
242242
.on('error', callback)
243243
.pipe(resOrSocket)
244-
.on('error', callback)
245244
.pipe(proxySocket)
246245
} catch (err) {
247246
callback(err)

0 commit comments

Comments
 (0)