refactor(socket-utils): replace direct socket cleanup with centralized cleanupSocket utility across connection management

This commit is contained in:
2025-06-01 08:02:32 +00:00
parent eb2e67fecc
commit bed1a76537
5 changed files with 19 additions and 58 deletions

View File

@ -2,6 +2,7 @@ import * as plugins from '../../plugins.js';
import type { ISmartProxyOptions } from './models/interfaces.js';
import { RouteConnectionHandler } from './route-connection-handler.js';
import { logger } from '../../core/utils/logger.js';
import { cleanupSocket } from '../../core/utils/socket-utils.js';
/**
* PortManager handles the dynamic creation and removal of port listeners
@ -64,8 +65,7 @@ export class PortManager {
const server = plugins.net.createServer((socket) => {
// Check if shutting down
if (this.isShuttingDown) {
socket.end();
socket.destroy();
cleanupSocket(socket, 'port-manager-shutdown');
return;
}