fix(PortProxy): Improve socket cleanup logic to prevent potential resource leaks
This commit is contained in:
		| @@ -1,5 +1,10 @@ | |||||||
| # Changelog | # Changelog | ||||||
|  |  | ||||||
|  | ## 2025-02-22 - 3.10.1 - fix(PortProxy) | ||||||
|  | Improve socket cleanup logic to prevent potential resource leaks | ||||||
|  |  | ||||||
|  | - Updated socket cleanup in PortProxy to ensure sockets are forcefully destroyed if not already destroyed. | ||||||
|  |  | ||||||
| ## 2025-02-22 - 3.10.0 - feat(smartproxy.portproxy) | ## 2025-02-22 - 3.10.0 - feat(smartproxy.portproxy) | ||||||
| Enhance PortProxy with detailed connection statistics and termination tracking | Enhance PortProxy with detailed connection statistics and termination tracking | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,6 +3,6 @@ | |||||||
|  */ |  */ | ||||||
| export const commitinfo = { | export const commitinfo = { | ||||||
|   name: '@push.rocks/smartproxy', |   name: '@push.rocks/smartproxy', | ||||||
|   version: '3.10.0', |   version: '3.10.1', | ||||||
|   description: 'a proxy for handling high workloads of proxying' |   description: 'a proxy for handling high workloads of proxying' | ||||||
| } | } | ||||||
|   | |||||||
| @@ -149,16 +149,12 @@ export class PortProxy { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   public async start() { |   public async start() { | ||||||
|     // Adjusted cleanUpSockets to allow an optional outgoing socket. |     // Adjusted cleanUpSockets: forcefully destroy both sockets if they haven't been destroyed. | ||||||
|     const cleanUpSockets = (from: plugins.net.Socket, to?: plugins.net.Socket) => { |     const cleanUpSockets = (from: plugins.net.Socket, to?: plugins.net.Socket) => { | ||||||
|       from.end(); |       if (!from.destroyed) { | ||||||
|       from.removeAllListeners(); |         from.destroy(); | ||||||
|       from.unpipe(); |       } | ||||||
|       from.destroy(); |       if (to && !to.destroyed) { | ||||||
|       if (to) { |  | ||||||
|         to.end(); |  | ||||||
|         to.removeAllListeners(); |  | ||||||
|         to.unpipe(); |  | ||||||
|         to.destroy(); |         to.destroy(); | ||||||
|       } |       } | ||||||
|     }; |     }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user