mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(e2e): abort kitchen sink readiness on gateway exit
This commit is contained in:
@@ -211,6 +211,48 @@ describe("kitchen-sink RPC gateway teardown", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("aborts stalled readiness probes when the gateway exits mid-probe", async () => {
|
||||
const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-exit-during-ready-"));
|
||||
try {
|
||||
const logPath = path.join(root, "gateway.log");
|
||||
writeFileSync(logPath, "gateway died during readiness\n");
|
||||
const child = Object.assign(new EventEmitter(), {
|
||||
exitCode: null,
|
||||
signalCode: null as NodeJS.Signals | null,
|
||||
});
|
||||
const fetchImpl = vi.fn((_url: string, init?: RequestInit) => {
|
||||
return new Promise((_resolve, reject) => {
|
||||
init?.signal?.addEventListener(
|
||||
"abort",
|
||||
() => {
|
||||
const reason = init.signal?.reason;
|
||||
reject(reason instanceof Error ? reason : new Error("fetch aborted"));
|
||||
},
|
||||
{ once: true },
|
||||
);
|
||||
});
|
||||
});
|
||||
const startedAt = Date.now();
|
||||
setTimeout(() => {
|
||||
child.signalCode = "SIGTERM";
|
||||
child.emit("exit", null, "SIGTERM");
|
||||
}, 25);
|
||||
|
||||
await expect(
|
||||
waitForGatewayReady(child, 9, logPath, {
|
||||
fetchImpl,
|
||||
pollDelayMs: 5_000,
|
||||
timeoutMs: 2_000,
|
||||
}),
|
||||
).rejects.toThrow("gateway exited before ready");
|
||||
|
||||
expect(fetchImpl).toHaveBeenCalledOnce();
|
||||
expect(Date.now() - startedAt).toBeLessThan(500);
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps stalled readiness probes inside the caller deadline", async () => {
|
||||
const root = mkdtempSync(path.join(tmpdir(), "openclaw-kitchen-rpc-stalled-ready-"));
|
||||
try {
|
||||
@@ -553,9 +595,7 @@ describe("kitchen-sink RPC command catalog assertions", () => {
|
||||
it("requires every expected Kitchen Sink plugin tool", () => {
|
||||
expect(() =>
|
||||
assertExpectedKitchenSinkToolEntries(
|
||||
[
|
||||
{ id: "kitchen_sink_text", source: "plugin", pluginId: "openclaw-kitchen-sink-fixture" },
|
||||
],
|
||||
[{ id: "kitchen_sink_text", source: "plugin", pluginId: "openclaw-kitchen-sink-fixture" }],
|
||||
"tools.catalog plugin tools",
|
||||
{ requirePluginProvenance: true },
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user