Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
import { describe, it } from "node:test";
import assert from "node:assert/strict";
import {
setDispatcherCacheEntry,
getDispatcherCache,
clearDispatcherCache,
} from "../../open-sse/utils/proxyDispatcherCache.ts";
describe("proxy dispatcher cache cap (#9158)", () => {
it("evicts and closes the oldest entry at the 512-entry cap", () => {
let closedCount = 0;
const fakeDispatcher = {
close() {
closedCount += 1;
return Promise.resolve();
},
} as never;
for (let i = 0; i <= 512; i += 1) {
setDispatcherCacheEntry(`u${i}`, fakeDispatcher);
}
assert.equal(getDispatcherCache().size, 512, "cache must stay at the cap");
assert.equal(closedCount, 1, "exactly one entry must be evicted and closed");
assert.equal(getDispatcherCache().has("u0"), false, "oldest entry must be evicted");
assert.equal(getDispatcherCache().has("u512"), true, "newest entry must be retained");
clearDispatcherCache();
});
});