fix: release Pi snapshots on failed initialization
This commit is contained in:
@@ -306,10 +306,18 @@ test("createFor kills a spawned child when post-spawn initialization throws", ()
|
||||
child.stdout = {
|
||||
on: () => { throw new Error("READER_INIT_SENTINEL"); },
|
||||
};
|
||||
const mgr = new PiProcessManager(loadConfig({}), { spawnFn: () => child as any });
|
||||
let snapshotDir: string | undefined;
|
||||
const mgr = new PiProcessManager(loadConfig({}), {
|
||||
spawnFn: (_command, _args, options) => {
|
||||
snapshotDir = options.env.PI_CODING_AGENT_DIR;
|
||||
return child as any;
|
||||
},
|
||||
});
|
||||
|
||||
expect(() => mgr.createFor("broken-init", {})).toThrow("READER_INIT_SENTINEL");
|
||||
|
||||
expect(snapshotDir).toBeTruthy();
|
||||
expect(existsSync(snapshotDir!)).toBe(false);
|
||||
expect(child.kill).toHaveBeenCalledOnce();
|
||||
expect(mgr.get("broken-init")).toBeUndefined();
|
||||
expect(mgr.count()).toBe(0);
|
||||
|
||||
Reference in New Issue
Block a user