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

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

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}`);
}