Files
openclaw/src/gateway/server-plugins.lifecycle.test.ts
Vincent Koc e8b4e39a97 fix(gateway): clear fallback context on close
Fixes gateway fallback request context cleanup on close/startup failure and shards the full gateway Vitest lane to avoid the observed memory hang.\n\nValidation:\n- Testbox: OPENCLAW_TESTBOX=1 pnpm check:changed\n- Testbox: env OPENCLAW_VITEST_MAX_WORKERS=1 /usr/bin/time -v pnpm test:gateway (254 files, 2950 tests, max RSS 4144692 KB)
2026-04-27 21:19:21 -07:00

29 lines
998 B
TypeScript

import { afterEach, describe, expect, it } from "vitest";
import { clearFallbackGatewayContext, createGatewaySubagentRuntime } from "./server-plugins.js";
import { installGatewayTestHooks, startServer } from "./test-helpers.server.js";
installGatewayTestHooks();
afterEach(() => {
clearFallbackGatewayContext();
});
describe("gateway plugin fallback context lifecycle", () => {
it("clears the fallback gateway context after server close", async () => {
const runtime = createGatewaySubagentRuntime();
const started = await startServer();
try {
await expect(
runtime.getSessionMessages({ sessionKey: "agent:main:main", limit: 1 }),
).resolves.toEqual({ messages: [] });
} finally {
await started.server.close({ reason: "fallback context lifecycle test done" });
}
await expect(
runtime.getSessionMessages({ sessionKey: "agent:main:main", limit: 1 }),
).rejects.toThrow("No scope set and no fallback context available");
});
});