mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 07:00:44 +00:00
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)
29 lines
998 B
TypeScript
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");
|
|
});
|
|
});
|