fix(PortProxy): Optimize connection cleanup logic in PortProxy by removing unnecessary delays.

This commit is contained in:
Philipp Kunz 2025-02-27 15:30:20 +00:00
parent b3ba0c21e8
commit 9af968b8e7
3 changed files with 7 additions and 5 deletions

View File

@ -1,5 +1,11 @@
# Changelog
## 2025-02-27 - 3.16.6 - fix(PortProxy)
Optimize connection cleanup logic in PortProxy by removing unnecessary delays.
- Removed multiple await plugins.smartdelay.delayFor(0) calls.
- Improved performance by ensuring timely resource release during connection termination.
## 2025-02-27 - 3.16.5 - fix(PortProxy)
Improved connection cleanup process with added asynchronous delays

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartproxy',
version: '3.16.5',
version: '3.16.6',
description: 'A robust and versatile proxy package designed to handle high workloads, offering features like SSL redirection, port proxying, WebSocket support, and customizable routing and authentication.'
}

View File

@ -143,15 +143,11 @@ export class PortProxy {
const cleanupOnce = async () => {
if (!connectionRecord.connectionClosed) {
connectionRecord.connectionClosed = true;
await plugins.smartdelay.delayFor(0);
if (connectionRecord.cleanupTimer) {
clearTimeout(connectionRecord.cleanupTimer);
}
await plugins.smartdelay.delayFor(0);
if (!socket.destroyed) socket.destroy();
await plugins.smartdelay.delayFor(0);
if (connectionRecord.outgoing && !connectionRecord.outgoing.destroyed) connectionRecord.outgoing.destroy();
await plugins.smartdelay.delayFor(0);
this.connectionRecords.delete(connectionRecord);
console.log(`Connection from ${remoteIP} terminated. Active connections: ${this.connectionRecords.size}`);
}