fix(hopper): preserve observed process failures across requests (#1927)
* fix(hopper): preserve observed process failures across requests * test(hopper): consolidate retained cleanup and recover failed helper fixtures * docs(hopper): clarify first-use demo prompt and startup recovery
This commit is contained in:
@@ -160,50 +160,71 @@ it("retains failed startup cleanup until an owned process and its backing image
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps an unconfirmed external document visible across sequential closes", async () => {
|
||||
const launcher = new RetryCleanupLauncher(true);
|
||||
const runtimeRoot = await PrivateRuntimeRoot.create();
|
||||
onTestFinished(() => runtimeRoot.close());
|
||||
const launched = await launcher.launch({
|
||||
directory: runtimeRoot.path,
|
||||
socketPath: join(runtimeRoot.path, "bridge.sock"),
|
||||
token: "fixture-token",
|
||||
runId: "fixture-run",
|
||||
});
|
||||
if (!launched.ok) throw launched.error;
|
||||
const child = launched.value.process;
|
||||
const supervisor = new ProviderProcessSupervisor(launched.value);
|
||||
onTestFinished(() => supervisor.dispose());
|
||||
const resources: HopperOwnedResources = {
|
||||
launch: launched.value,
|
||||
processSupervisor: supervisor,
|
||||
runtimeRoot,
|
||||
shutdownConfirmed: false,
|
||||
};
|
||||
for (let attempt = 0; attempt < 2; attempt += 1) {
|
||||
await expect(
|
||||
cleanupHopperSession({
|
||||
socket: undefined,
|
||||
resources,
|
||||
activeRequest: null,
|
||||
retainDocument: false,
|
||||
progress: undefined,
|
||||
logger: silentLogger,
|
||||
onDiagnostic: undefined,
|
||||
request: () => Promise.resolve(ok(null)),
|
||||
releaseTransport: (socket) => socket?.destroy(),
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
error: { cleanupResources: ["hopper-document", runtimeRoot.path] },
|
||||
it.each([false, true])(
|
||||
"keeps an unconfirmed external document across closes when helper ownership is %s",
|
||||
async (ownsHelper) => {
|
||||
const launcher = new RetryCleanupLauncher(true);
|
||||
const runtimeRoot = await PrivateRuntimeRoot.create();
|
||||
onTestFinished(() => runtimeRoot.close());
|
||||
const launched = await launcher.launch({
|
||||
directory: runtimeRoot.path,
|
||||
socketPath: join(runtimeRoot.path, "bridge.sock"),
|
||||
token: "fixture-token",
|
||||
runId: "fixture-run",
|
||||
});
|
||||
}
|
||||
expect(child.exitCode).toBeNull();
|
||||
expect(child.signalCode).toBeNull();
|
||||
await expect(
|
||||
access(join(runtimeRoot.path, "image.macho")),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
if (!launched.ok) throw launched.error;
|
||||
const child = launched.value.process;
|
||||
const launch: BridgeLaunch = ownsHelper
|
||||
? { ...launched.value, ownsProcessLifetime: true }
|
||||
: launched.value;
|
||||
const supervisor = new ProviderProcessSupervisor(launch);
|
||||
onTestFinished(() => supervisor.dispose());
|
||||
const resources: HopperOwnedResources = {
|
||||
launch,
|
||||
processSupervisor: supervisor,
|
||||
runtimeRoot,
|
||||
shutdownConfirmed: false,
|
||||
};
|
||||
const socket = new Socket();
|
||||
onTestFinished(() => {
|
||||
socket.destroy();
|
||||
});
|
||||
for (let attempt = 0; attempt < 2; attempt += 1) {
|
||||
await expect(
|
||||
cleanupHopperSession({
|
||||
socket: attempt === 0 ? socket : undefined,
|
||||
resources,
|
||||
activeRequest: null,
|
||||
retainDocument: false,
|
||||
progress: undefined,
|
||||
logger: silentLogger,
|
||||
onDiagnostic: undefined,
|
||||
request: () =>
|
||||
Promise.resolve(
|
||||
ok({
|
||||
shutdown: true,
|
||||
analysis_stopped: true,
|
||||
document_closed: false,
|
||||
}),
|
||||
),
|
||||
releaseTransport: (socket) => socket?.destroy(),
|
||||
}),
|
||||
).resolves.toMatchObject({
|
||||
ok: false,
|
||||
error: { cleanupResources: ["hopper-document", runtimeRoot.path] },
|
||||
});
|
||||
}
|
||||
if (ownsHelper)
|
||||
expect(child.exitCode !== null || child.signalCode !== null).toBe(true);
|
||||
else {
|
||||
expect(child.exitCode).toBeNull();
|
||||
expect(child.signalCode).toBeNull();
|
||||
}
|
||||
await expect(
|
||||
access(join(runtimeRoot.path, "image.macho")),
|
||||
).resolves.toBeUndefined();
|
||||
},
|
||||
);
|
||||
|
||||
it("blocks a fresh launch while cleanup remains unverified", async () => {
|
||||
const launcher = new RetryCleanupLauncher();
|
||||
|
||||
Reference in New Issue
Block a user