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

View File

@@ -2,15 +2,17 @@ import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as net from 'net';
import * as tls from 'tls';
import { SmartProxy } from '../ts/index.js';
import { findFreePorts, assertPortsFree } from './helpers/port-allocator.js';
let testProxy: SmartProxy;
let targetServer: net.Server;
const ECHO_PORT = 47200;
const PROXY_PORT = 47201;
let ECHO_PORT: number;
let PROXY_PORT: number;
// Create a simple echo server as target
tap.test('setup test environment', async () => {
[ECHO_PORT, PROXY_PORT] = await findFreePorts(2);
// Create target server that echoes data back
targetServer = net.createServer((socket) => {
console.log('Target server: client connected');
@@ -148,6 +150,8 @@ tap.test('cleanup', async () => {
resolve();
});
});
await assertPortsFree([ECHO_PORT, PROXY_PORT]);
});
export default tap.start();