Skip to content

Commit e6fbead

Browse files
committed
Revert "fix: release on error & close"
This reverts commit 758429c.
1 parent 758429c commit e6fbead

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

index.js

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ function createError (msg, code, statusCode) {
212212

213213
class ErrorHandler {
214214
constructor () {
215-
this.released = true
216215
this.hasError = false
217216
this.req = null
218217
this.resOrSocket = null
@@ -252,11 +251,6 @@ class ErrorHandler {
252251
}
253252

254253
_release () {
255-
if (this.released) {
256-
return
257-
}
258-
259-
this.released = true
260254
this.hasError = false
261255
this.req = null
262256
this.resOrSocket = null
@@ -267,21 +261,18 @@ class ErrorHandler {
267261

268262
static create (req, resOrSocket, callback) {
269263
const handler = ErrorHandler.pool.pop() || new ErrorHandler()
270-
handler.released = false
271264
handler.hasError = false
272265
handler.req = req
273266
handler.resOrSocket = resOrSocket
274267
handler.callback = callback
275268
handler.req.on('close', handler._release)
276-
handler.req.on('error', handler._release)
277269
return handler._handle
278270
}
279271
}
280272
ErrorHandler.pool = []
281273

282274
class ProxyErrorHandler {
283275
constructor () {
284-
this.released = true
285276
this.hasError = false
286277
this.req = null
287278
this.proxyReq = null
@@ -332,13 +323,8 @@ class ProxyErrorHandler {
332323
}
333324

334325
_release () {
335-
if (this.released) {
336-
return
337-
}
338-
339326
this._abort()
340327

341-
this.released = true
342328
this.hasError = false
343329
this.req = null
344330
this.proxyReq = null
@@ -349,20 +335,17 @@ class ProxyErrorHandler {
349335

350336
static create (req, proxyReq, errorHandler) {
351337
const handler = ProxyErrorHandler.pool.pop() || new ProxyErrorHandler()
352-
handler.released = false
353338
handler.req = req
354339
handler.proxyReq = proxyReq
355340
handler.errorHandler = errorHandler
356341
handler.req.on('close', handler._release)
357-
handler.req.on('error', handler._release)
358342
return handler._handle
359343
}
360344
}
361345
ProxyErrorHandler.pool = []
362346

363347
class ProxyResponseHandler {
364348
constructor () {
365-
this.released = true
366349
this.req = null
367350
this.resOrSocket = null
368351
this.onRes = null
@@ -412,15 +395,10 @@ class ProxyResponseHandler {
412395
}
413396

414397
_release () {
415-
if (this.released) {
416-
return
417-
}
418-
419398
if (this.proxyRes) {
420399
this.proxyRes.destroy()
421400
}
422401

423-
this.released = true
424402
this.req = null
425403
this.resOrSocket = null
426404
this.onRes = null
@@ -432,22 +410,19 @@ class ProxyResponseHandler {
432410

433411
static create (req, resOrSocket, onRes, proxyErrorHandler) {
434412
const handler = ProxyResponseHandler.pool.pop() || new ProxyResponseHandler()
435-
handler.released = false
436413
handler.req = req
437414
handler.resOrSocket = resOrSocket
438415
handler.onRes = onRes
439416
handler.proxyErrorHandler = proxyErrorHandler
440417
handler.proxyRes = null
441418
handler.req.on('close', handler._release)
442-
handler.req.on('error', handler._release)
443419
return handler._handle
444420
}
445421
}
446422
ProxyResponseHandler.pool = []
447423

448424
class ProxyUpgradeHandler {
449425
constructor () {
450-
this.released = true
451426
this.req = null
452427
this.resOrSocket = null
453428
this.proxyErrorHandler = null
@@ -495,18 +470,13 @@ class ProxyUpgradeHandler {
495470
}
496471

497472
_release () {
498-
if (this.released) {
499-
return
500-
}
501-
502473
if (this.proxyRes) {
503474
this.proxyRes.destroy()
504475
}
505476
if (this.proxySocket) {
506477
this.proxySocket.destroy()
507478
}
508479

509-
this.released = true
510480
this.req = null
511481
this.resOrSocket = null
512482
this.proxyErrorHandler = null
@@ -518,12 +488,10 @@ class ProxyUpgradeHandler {
518488

519489
static create (req, resOrSocket, proxyErrorHandler) {
520490
const handler = ProxyUpgradeHandler.pool.pop() || new ProxyUpgradeHandler()
521-
handler.released = false
522491
handler.req = req
523492
handler.resOrSocket = resOrSocket
524493
handler.proxyErrorHandler = proxyErrorHandler
525494
handler.req.on('close', handler._release)
526-
handler.req.on('error', handler._release)
527495
return handler._handle
528496
}
529497
}

0 commit comments

Comments
 (0)