mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:40:43 +00:00
fix(gateway): keep restart emitting after ack prep failure
This commit is contained in:
@@ -133,6 +133,27 @@ describe("infra runtime", () => {
|
||||
expect(afterEmitRejected).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("still emits restart when preparation fails", async () => {
|
||||
const beforeEmit = vi.fn(async () => {
|
||||
throw new Error("state dir readonly");
|
||||
});
|
||||
const emitSpy = vi.spyOn(process, "emit");
|
||||
const handler = () => {};
|
||||
process.on("SIGUSR1", handler);
|
||||
try {
|
||||
scheduleGatewaySigusr1Restart({
|
||||
delayMs: 0,
|
||||
emitHooks: { beforeEmit },
|
||||
});
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
|
||||
expect(beforeEmit).toHaveBeenCalledTimes(1);
|
||||
expect(emitSpy).toHaveBeenCalledWith("SIGUSR1");
|
||||
} finally {
|
||||
process.removeListener("SIGUSR1", handler);
|
||||
}
|
||||
});
|
||||
|
||||
it("applies restart cooldown between emitted restart cycles", async () => {
|
||||
const emitSpy = vi.spyOn(process, "emit");
|
||||
const handler = () => {};
|
||||
|
||||
@@ -206,8 +206,7 @@ async function emitPreparedGatewayRestart(hooks?: RestartEmitHooks): Promise<voi
|
||||
try {
|
||||
await hooks?.beforeEmit?.();
|
||||
} catch (err) {
|
||||
restartLog.warn(`restart preparation failed; restart not emitted: ${String(err)}`);
|
||||
return;
|
||||
restartLog.warn(`restart preparation failed; restart will continue without it: ${String(err)}`);
|
||||
}
|
||||
|
||||
const emitted = emitGatewayRestart();
|
||||
|
||||
Reference in New Issue
Block a user