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,14 +2,16 @@ import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as plugins from '../ts/plugins.js';
import { SmartProxy } from '../ts/index.js';
import * as net from 'net';
import { findFreePorts, assertPortsFree } from './helpers/port-allocator.js';
let smartProxyInstance: SmartProxy;
let echoServer: net.Server;
const echoServerPort = 47300;
const proxyPort = 47301;
let echoServerPort: number;
let proxyPort: number;
// Create an echo server for testing
tap.test('should create echo server for testing', async () => {
[echoServerPort, proxyPort] = await findFreePorts(2);
echoServer = net.createServer((socket) => {
socket.on('data', (data) => {
socket.write(data); // Echo back the data
@@ -267,6 +269,8 @@ tap.test('should clean up resources', async () => {
resolve();
});
});
await assertPortsFree([echoServerPort, proxyPort]);
});
export default tap.start();