fix(rustproxy): Use cooperative cancellation for background tasks, prune stale caches and metric entries, and switch tests to dynamic port allocation to avoid port conflicts

This commit is contained in:
2026-02-24 20:56:37 +00:00
parent 755c81c042
commit 33cd5330c4
24 changed files with 535 additions and 560 deletions
+6 -3
View File
@@ -1,17 +1,19 @@
import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as net from 'net';
import { SmartProxy } from '../ts/proxies/smart-proxy/smart-proxy.js';
import { findFreePorts, assertPortsFree } from './helpers/port-allocator.js';
let echoServer: net.Server;
let proxy: SmartProxy;
const ECHO_PORT = 47400;
const PROXY_PORT_1 = 47401;
const PROXY_PORT_2 = 47402;
let ECHO_PORT: number;
let PROXY_PORT_1: number;
let PROXY_PORT_2: number;
tap.test('port forwarding should not immediately close connections', async (tools) => {
// Set a timeout for this test
tools.timeout(10000); // 10 seconds
[ECHO_PORT, PROXY_PORT_1, PROXY_PORT_2] = await findFreePorts(3);
// Create an echo server
echoServer = await new Promise<net.Server>((resolve, reject) => {
const server = net.createServer((socket) => {
@@ -96,6 +98,7 @@ tap.test('cleanup', async () => {
});
});
}
await assertPortsFree([ECHO_PORT, PROXY_PORT_1, PROXY_PORT_2]);
});
export default tap.start();