update
This commit is contained in:
@ -6,6 +6,7 @@ import { startTestServer, stopTestServer } from '../../helpers/server.loader.js'
|
||||
const TEST_PORT = 2525;
|
||||
|
||||
let testServer;
|
||||
const activeSockets = new Set<net.Socket>();
|
||||
|
||||
tap.test('prepare server', async () => {
|
||||
testServer = await startTestServer({ port: TEST_PORT });
|
||||
@ -19,6 +20,9 @@ tap.test('ERR-07: Exception handling - Invalid commands', async (tools) => {
|
||||
port: TEST_PORT,
|
||||
timeout: 30000
|
||||
});
|
||||
|
||||
activeSockets.add(socket);
|
||||
socket.on('close', () => activeSockets.delete(socket));
|
||||
|
||||
socket.on('connect', async () => {
|
||||
try {
|
||||
@ -147,6 +151,9 @@ tap.test('ERR-07: Exception handling - Malformed protocol', async (tools) => {
|
||||
port: TEST_PORT,
|
||||
timeout: 30000
|
||||
});
|
||||
|
||||
activeSockets.add(socket);
|
||||
socket.on('close', () => activeSockets.delete(socket));
|
||||
|
||||
socket.on('connect', async () => {
|
||||
try {
|
||||
@ -224,6 +231,9 @@ tap.test('ERR-07: Exception handling - Recovery after errors', async (tools) =>
|
||||
port: TEST_PORT,
|
||||
timeout: 30000
|
||||
});
|
||||
|
||||
activeSockets.add(socket);
|
||||
socket.on('close', () => activeSockets.delete(socket));
|
||||
|
||||
socket.on('connect', async () => {
|
||||
try {
|
||||
@ -307,6 +317,16 @@ tap.test('ERR-07: Exception handling - Recovery after errors', async (tools) =>
|
||||
});
|
||||
|
||||
tap.test('cleanup server', async () => {
|
||||
// Close any remaining sockets
|
||||
for (const socket of activeSockets) {
|
||||
if (!socket.destroyed) {
|
||||
socket.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all sockets to be fully closed
|
||||
await new Promise(resolve => setTimeout(resolve, 500));
|
||||
|
||||
await stopTestServer(testServer);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user