Avoid duplicate backend shutdown notifications

This commit is contained in:
Josh Gratton committed 2026-06-02 16:45:06 -04:00
1 parent b9e12d3377
commit e3448d0199
2 files changed
+31 -1

No files matched your search

@@ -416,6 +416,36 @@ describe("DesktopBackendManager", () => {
),
);
it.effect("does not notify shutdown when a scheduled restart starts from non-ready state", () =>
Effect.scoped(
Effect.gen(function* () {
let shutdownCount = 0;
const spawnerLayer = Layer.succeed(
ChildProcessSpawner.ChildProcessSpawner,
ChildProcessSpawner.make(() => Effect.die("unexpected backend spawn")),
);
const instance = yield* makeTestInstance({
spawnerLayer,
config: {
...baseConfig,
preflightFailure: Option.some("preflight failed"),
},
onShutdown: Effect.sync(() => {
shutdownCount += 1;
}),
});
yield* instance.start;
assert.equal(shutdownCount, 0);
yield* TestClock.adjust(Duration.millis(500));
assert.equal(shutdownCount, 0);
}).pipe(Effect.provide(TestClock.layer())),
),
);
it.effect("cancels a scheduled restart when start is requested manually", () =>
Effect.scoped(
Effect.gen(function* () {
@@ -408,7 +408,7 @@ export const makeBackendInstance = Effect.fn("makeBackendInstance")(function* (
return;
}
if (current.ready || Option.isSome(current.config)) {
if (current.ready) {
yield* spec.onShutdown?.() ?? Effect.void;
}
const config = yield* spec.configResolve.pipe(