Skip to content

Commit b84a665

Browse files
committed
fix: use kFinished
1 parent edf4067 commit b84a665

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const kProxyReq = Symbol('proxyReq')
3939
const kProxyRes = Symbol('proxyRes')
4040
const kProxySocket = Symbol('proxySocket')
4141
const kOnProxyRes = Symbol('onProxyRes')
42+
const kFinished = Symbol('finished')
4243

4344
const RESPOND_OPTIONS = {
4445
getTrailers: function () {
@@ -75,6 +76,7 @@ function proxy (req, res, head, {
7576
res[kProxyReq] = null
7677
res[kProxyRes] = null
7778
res[kProxySocket] = null
79+
res[kFinished] = false
7880

7981
assert(typeof callback === 'function' || callback == null)
8082

@@ -178,10 +180,12 @@ function onFinish (err, statusCode = 500) {
178180

179181
assert(res)
180182

181-
if (!res[kProxyCallback]) {
183+
if (res[kFinished]) {
182184
return
183185
}
184186

187+
res[kFinished] = true
188+
185189
if (err) {
186190
err.statusCode = statusCode || err.statusCode || 500
187191
err.code = err.code || res.code

0 commit comments

Comments
 (0)