diff --git a/src/infra/infra-runtime.test.ts b/src/infra/infra-runtime.test.ts index c7861bda72c..2eff8dc0ba1 100644 --- a/src/infra/infra-runtime.test.ts +++ b/src/infra/infra-runtime.test.ts @@ -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 = () => {}; diff --git a/src/infra/restart.ts b/src/infra/restart.ts index 054805794c3..03c45fc5350 100644 --- a/src/infra/restart.ts +++ b/src/infra/restart.ts @@ -206,8 +206,7 @@ async function emitPreparedGatewayRestart(hooks?: RestartEmitHooks): Promise