fix: make session resume atomic across restarts
This commit is contained in:
@@ -84,6 +84,36 @@ function recordingChild() {
|
||||
return ch;
|
||||
}
|
||||
|
||||
test("createFor kills a spawned child when post-spawn initialization throws", () => {
|
||||
const child = recordingChild();
|
||||
child.kill = vi.fn();
|
||||
child.stdout = {
|
||||
on: () => { throw new Error("READER_INIT_SENTINEL"); },
|
||||
};
|
||||
const mgr = new PiProcessManager(loadConfig({}), { spawnFn: () => child as any });
|
||||
|
||||
expect(() => mgr.createFor("broken-init", {})).toThrow("READER_INIT_SENTINEL");
|
||||
|
||||
expect(child.kill).toHaveBeenCalledOnce();
|
||||
expect(mgr.get("broken-init")).toBeUndefined();
|
||||
expect(mgr.count()).toBe(0);
|
||||
});
|
||||
|
||||
test("createFor kills a spawned child when spawn boundary initialization throws", () => {
|
||||
const child = recordingChild();
|
||||
child.kill = vi.fn();
|
||||
child.stderr = {
|
||||
on: () => { throw new Error("STDERR_INIT_SENTINEL"); },
|
||||
};
|
||||
const mgr = new PiProcessManager(loadConfig({}), { spawnFn: () => child as any });
|
||||
|
||||
expect(() => mgr.createFor("broken-spawn-init", {})).toThrow("STDERR_INIT_SENTINEL");
|
||||
|
||||
expect(child.kill).toHaveBeenCalledOnce();
|
||||
expect(mgr.get("broken-spawn-init")).toBeUndefined();
|
||||
expect(mgr.count()).toBe(0);
|
||||
});
|
||||
|
||||
test("un exit INATTESO del child notifica il client (info error + agent_end)", async () => {
|
||||
const cfg = loadConfig({});
|
||||
const child = recordingChild();
|
||||
|
||||
Reference in New Issue
Block a user