Skip to content

Commit 257f679

Browse files
committed
fix: upgrade proxy memleak
1 parent 0b1be2f commit 257f679

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,17 @@ class ProxyUpgradeHandler {
438438
this.req = null
439439
this.resOrSocket = null
440440
this.onProxyError = null
441+
this.proxyRes = null
442+
this.proxySocket = null
441443

442444
this._handle = this._handle.bind(this)
443445
this._release = this._release.bind(this)
444446
}
445447

446448
_handle (proxyRes, proxySocket, proxyHead) {
449+
this.proxyRes = proxyRes
450+
this.proxySocket = proxySocket
451+
447452
try {
448453
setupSocket(proxySocket)
449454

@@ -482,10 +487,14 @@ class ProxyUpgradeHandler {
482487

483488
_release () {
484489
this.req.removeListener('close', this._release)
490+
this.proxyRes.destroy()
491+
this.proxySocket.destroy()
485492

486493
this.req = null
487494
this.resOrSocket = null
488495
this.onProxyError = null
496+
this.proxyRes = null
497+
this.proxySocket = null
489498
ProxyUpgradeHandler.pool.push(this)
490499
}
491500

0 commit comments

Comments
 (0)