fix: serialize every download start through lifecycle
Route full, package, and item starts through a shared typed start request lifecycle. Preserve targeted scopes while a stop drains, publish pending-start state consistently, and dispatch the accepted request only after the old work has settled. Add package and item regression coverage and update the notification lifecycle assertion to the pending/drain contract.
This commit is contained in:
@@ -664,11 +664,13 @@ describe("authoritative run completion", () => {
|
||||
|
||||
const packageB = addPackage(session, ["queued"], "follow-up-package");
|
||||
await manager.start();
|
||||
expect(session.running).toBe(true);
|
||||
expect(state.runPackageIds).toEqual(new Set([packageB.id]));
|
||||
expect(session.running).toBe(false);
|
||||
expect(manager.getSnapshot().lifecycle).toMatchObject({ phase: "stopping", pendingStart: true });
|
||||
|
||||
releasePostProcess();
|
||||
await latePostProcess;
|
||||
await vi.waitFor(() => expect(manager.getSnapshot().lifecycle).toMatchObject({ phase: "running", pendingStart: false }));
|
||||
expect(state.runPackageIds).toEqual(new Set([packageB.id]));
|
||||
await flushNotifications();
|
||||
expect(events.filter((event) => event.type === "package_completed")).toHaveLength(0);
|
||||
expect(history).toHaveLength(0);
|
||||
|
||||
Reference in New Issue
Block a user