Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/absorb-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,10 @@ async function startRig(baseCompress: Record<string, unknown>, routeCompress?: R

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
2 changes: 2 additions & 0 deletions tests/anthropic-beta-window.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ function hasEmergencyNudge(body: string): boolean {

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
2 changes: 2 additions & 0 deletions tests/cache-friendly-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,10 @@ async function driveWire(wire: Wire, steps: Step[], opts?: DriveOpts): Promise<C
}
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
if (prevXdg === undefined) delete process.env.XDG_STATE_HOME;
else process.env.XDG_STATE_HOME = prevXdg;
Expand Down
1 change: 1 addition & 0 deletions tests/cache-seam-fuzz.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function listen(srv: http.Server): Promise<void> {
}
async function closeServer(srv: http.Server): Promise<void> {
srv.close();
srv.closeIdleConnections?.();
await Promise.race([once(srv, "close"), new Promise((r) => setTimeout(r, 2000))]);
}

Expand Down
1 change: 1 addition & 0 deletions tests/cache-seam-probes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function listen(srv: http.Server): Promise<void> {
}
async function closeServer(srv: http.Server): Promise<void> {
srv.close();
srv.closeIdleConnections?.();
await Promise.race([once(srv, "close"), new Promise((r) => setTimeout(r, 2000))]);
}

Expand Down
12 changes: 7 additions & 5 deletions tests/ccr-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,13 @@ test("native retrieval bridge preserves proxy compression ownership", async () =
}
});

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
await once(rig.proxy, "close");
rig.upstream.close();
await once(rig.upstream, "close");
async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

test("native retrieval exports preserve each session's original when refs collide", async () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/claude-bridge-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ async function startRig(): Promise<Rig> {
scripts,
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
},
};
Expand Down
2 changes: 2 additions & 0 deletions tests/codex-compact-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,10 @@ async function withHarness(opts: { mode?: string; firstTurnTokens: number; stric
await fn(h);
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
delete process.env.BILI_CODEX_COMPACT;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/codex-local-compaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ async function startHarness(): Promise<Harness> {
bodies,
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
},
};
Expand Down
2 changes: 2 additions & 0 deletions tests/codex-window-align.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ function effectiveLimit(session: string): number | undefined {

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
2 changes: 2 additions & 0 deletions tests/compaction-trigger-finality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ test("e2e #280r2 (Responses): trailing compaction_trigger stays final — nudge
assert.ok(bodies[bodies.length - 1].includes("Context limit reached"), "nudge still injected on a normal request");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
2 changes: 2 additions & 0 deletions tests/configured-window-outranks-registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ function url(rig: Rig): string {

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
2 changes: 1 addition & 1 deletion tests/context-provenance-outbound.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async function harness(wire: Wire) {
assert.equal(r.status, 200);
return await r.json() as Status;
};
return { send, status, forwarded, setUsage: (value: boolean) => { usage = value; }, setFail: () => { fail = true; }, close: async () => { store.cancelAll(); proxy.close(); upstream.close(); await Promise.all([once(proxy, "close"), once(upstream, "close")]); } };
return { send, status, forwarded, setUsage: (value: boolean) => { usage = value; }, setFail: () => { fail = true; }, close: async () => { store.cancelAll(); proxy.close(); proxy.closeIdleConnections?.(); upstream.close(); upstream.closeIdleConnections?.(); await Promise.all([once(proxy, "close"), once(upstream, "close")]); } };
}

for (const wire of ["anthropic", "openai", "responses", "google"] as const) {
Expand Down
2 changes: 1 addition & 1 deletion tests/dsh-fork-adopt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ async function fullChainHarness() {
await once(proxy, "listening");
const paddr = proxy.address();
assert(paddr && typeof paddr === "object");
return { store, upstreamUrl, origin: `http://127.0.0.1:${paddr.port}`, close: async () => { store.cancelAll(); proxy.close(); upstream.close(); await Promise.all([once(proxy, "close"), once(upstream, "close")]); } };
return { store, upstreamUrl, origin: `http://127.0.0.1:${paddr.port}`, close: async () => { store.cancelAll(); proxy.close(); proxy.closeIdleConnections?.(); upstream.close(); upstream.closeIdleConnections?.(); await Promise.all([once(proxy, "close"), once(upstream, "close")]); } };
}

test("full chain: dsh fork child adopts the parent state and its replay is accepted (#2399)", async () => {
Expand Down
2 changes: 2 additions & 0 deletions tests/dsh-persona-continuity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,10 @@ async function startRig(): Promise<Rig> {

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
2 changes: 2 additions & 0 deletions tests/dsh-persona-fingerprint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@ async function startRig(upstreamHandler: UpstreamHandler = chatCompletionUpstrea

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
2 changes: 2 additions & 0 deletions tests/durable-tool-identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ async function startRig(compress?: CompressSettings): Promise<Rig> {

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e-anthropic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ async function startHarness(scripts: string[][]): Promise<Harness> {
captured,
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
},
};
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e-overflow-selfheal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,10 @@ test("e2e #987/#1195 T1: a stated-window overflow arms the one-shot shrink, lear
assert.equal(s2?.metadata.confirmedContextLimits, undefined, "still nothing learned after recovery");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
Expand Down Expand Up @@ -256,8 +258,10 @@ test("e2e #987 T2: an overflow WITHOUT a window number arms at the declared wind
assert.equal(summaryCalls, 0, "no fold");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
Expand Down Expand Up @@ -333,8 +337,10 @@ test("e2e #987 T3: with a CORRECT declared window, an oversized turn still recov
assert.ok(lastForward.includes(SUMMARY_TEXT), "the forwarded body carries the fold summary");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
6 changes: 6 additions & 0 deletions tests/e2e-relay-5xx-selfheal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ test("e2e #604: relay 5xx on near-window payload → arm → next retry truncate
assert.equal(s2?.stats.lastInputTokens, 5000, "real usage report overwrote the armed value");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
relay.server.close();
relay.server.closeIdleConnections?.();
await once(relay.server, "close");
}
});
Expand Down Expand Up @@ -302,8 +304,10 @@ test("e2e #604: network-level failure arms the emergency shrink too", async () =
assert.equal(s2?.stats.lastInputTokens, 5000, "real usage report overwrote the armed value");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
relay.server.close();
relay.server.closeIdleConnections?.();
await once(relay.server, "close");
}
});
Expand Down Expand Up @@ -333,8 +337,10 @@ test("e2e #604: 4xx (auth) must NOT arm — no distortion of the usage signal",
assert.equal(s!.stats.lastInputTokens, 0, "4xx must not raise lastInputTokens (no usage signal distortion)");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
relay.server.close();
relay.server.closeIdleConnections?.();
await once(relay.server, "close");
}
});
2 changes: 2 additions & 0 deletions tests/e2e-responses-mid-developer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ async function withHarness(handler: (raw: string, bodies: string[]) => string, f
await fn(h);
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/e2e-session-identity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ async function startHarness(upstreamCount = 1): Promise<Harness> {
upstreams,
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
await Promise.all(upstreams.map((u) => u.close()));
},
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e-tag-echo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ function startHarness(scripts: string[][]): Promise<Harness> {
captured,
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
},
};
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e-trae-model-restamp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ test("proxy e2e: model-switch history re-stamp re-attaches the anonymous session
} finally {
setLogCapture(null);
proxy.close();
proxy.closeIdleConnections?.();
relay.close();
relay.closeIdleConnections?.();
await Promise.allSettled([once(proxy, "close"), once(relay, "close")]);
}
});
4 changes: 4 additions & 0 deletions tests/e2e/e2e-image-billing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,10 @@ test("e2e real payload: bytes route 743x-poisoned, learned cost rescues, baselin
assert.notEqual(baseline, WINDOW - 2_000, "stale stamped baseline replaced");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
Expand Down Expand Up @@ -443,8 +445,10 @@ test("e2e default route: auto->pixels de-poisoned, malformed image rides along,
assert.equal(entry?.fp, "pixels:0", "default route learns under the pixels fingerprint");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
2 changes: 2 additions & 0 deletions tests/external-summary-badge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ async function startHarness(): Promise<Harness> {
upstreamPort,
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
},
};
Expand Down
4 changes: 4 additions & 0 deletions tests/fake-completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,10 @@ function startHarness(scripts: string[][], extra?: Partial<ProxyOptions>): Promi
captured,
close: async () => {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
},
};
Expand Down Expand Up @@ -435,8 +437,10 @@ test("e2e #1900: role learned mid-request (400 → hop) — hinted retry carries
assert.ok(!raw.includes("/fake/completion/marker"), "fake-completion text must not leak to the client");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
Expand Down
4 changes: 4 additions & 0 deletions tests/fallback-window-floor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ test("e2e: fallback-derived window is floored at 100k after output-headroom rese
assert.equal(received[1].length, 30, "turn 2 appends no nudge at 50% of the floored 100k window (would be 31 at 78% of the unfloored 64k)");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
Expand Down Expand Up @@ -216,8 +218,10 @@ test("e2e: per-route context declaration is operator-owned and never floored", a
assert.equal(received[1].length, 31, "operator-declared window is not floored: nudge appended at 78% of 64k");
} finally {
proxy.close();
proxy.closeIdleConnections?.();
await once(proxy, "close");
upstream.close();
upstream.closeIdleConnections?.();
await once(upstream, "close");
}
});
2 changes: 2 additions & 0 deletions tests/first-sight-drain-wire.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ const NUDGE_HINT = "ONE call, ONE string"; // rides every rendered nudge (ONE_CA

async function closeRig(rig: Rig): Promise<void> {
rig.proxy.close();
rig.proxy.closeIdleConnections?.();
await once(rig.proxy, "close");
rig.upstream.close();
rig.upstream.closeIdleConnections?.();
await once(rig.upstream, "close");
}

Expand Down
Loading
Loading