Files
OmniRoute/tests/unit/proxy-nested-context-skip.test.ts
Paijo 6c0437f136 fix(proxy): restore connection pooling on proxy/relay paths (#9100) (#9158)
Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates green: static + changed tests + vitest — only pre-existing audit.test.ts flake). Evidence: /home/diegosouzapw/dev/proxys/OmniRoute/.claude/worktrees/merge-train-20260805-213228-suite.log
2026-08-05 21:43:55 -03:00

35 lines
1.2 KiB
TypeScript

import { describe, it } from "node:test";
import assert from "node:assert/strict";
import { runWithProxyContext } from "../../open-sse/utils/proxyFetch.ts";
import { proxyConfigToUrl } from "../../open-sse/utils/proxyDispatcher.ts";
import {
invalidateProxyHealth,
__setProxyHealthTcpCheckForTesting,
} from "../../src/lib/proxyHealth.ts";
describe("runWithProxyContext nested same-context skip (#9158)", () => {
it("skips the reachability probe for a nested same-config call", async () => {
const cfg = { type: "http" as const, host: "127.0.0.1", port: 8080 };
const proxyUrl = proxyConfigToUrl(cfg)!;
assert.ok(proxyUrl);
let probeCount = 0;
__setProxyHealthTcpCheckForTesting(async () => {
probeCount += 1;
return true;
});
try {
const result = await runWithProxyContext(cfg, () => {
invalidateProxyHealth(proxyUrl);
return runWithProxyContext(cfg, () => "nested-marker");
});
assert.equal(result, "nested-marker");
assert.equal(probeCount, 1, "nested same-context call must skip the reachability probe");
} finally {
__setProxyHealthTcpCheckForTesting(null);
invalidateProxyHealth(proxyUrl);
}
});
});