fix(artifacts): retain ASAR resources through cleanup failures

Give snapshot capture, header admission, packed members, and container streams one file-handle owner. Serialize adoption with reader shutdown, retain failed closes for retry, and remove snapshots only after descriptor cleanup succeeds.

Cover unread members, pending opens, zero-byte members, and paired format/cleanup failures. Keep intentionally unrecoverable test fixtures hygienic and strengthen managed identity and process cleanup-authority expectations.

Validation: full npm run check; 99 targeted tests and temporary-directory hygiene; exact discovery of 877 test files. No real vendor-provider verification was performed.
This commit is contained in:
morluto
2026-10-12 05:05:21 +08:00
parent 290d301ec7
commit eb97da3388
7 changed files with 670 additions and 222 deletions
+20 -8
View File
@@ -285,12 +285,17 @@ describe("provider process output and cleanup primitives", () => {
await stopProviderProcessFixture(child);
}
});
});
describe("provider process cleanup authority", () => {
it("honors verified group cleanup instead of direct process signaling", async () => {
const child = spawnProviderProcessFixture("stubborn");
await waitForProviderProcessReady(child);
const signalFromCleanup = child.kill.bind(child);
const directSignal = vi.spyOn(child, "kill");
const cleanup = vi.fn(async () => {
child.kill("SIGKILL");
// Keep the injected cleanup signal separate from the supervisor's
// direct method, while retaining the child handle's lifetime checks.
signalFromCleanup("SIGKILL");
return { cleaned: true, signaled: true } as const;
});
const supervisor = new ProviderProcessSupervisor({
@@ -299,12 +304,19 @@ describe("provider process output and cleanup primitives", () => {
cleanup,
});
await expect(supervisor.stop({ killGraceMs: 500 })).resolves.toEqual({
status: "verified-cleanup",
});
// Cleanup must be attempted. The exact attempt count is an internal retry
// ladder, so it is deliberately not pinned here.
expect(cleanup).toHaveBeenCalled();
try {
await waitForProviderProcessReady(child);
await expect(supervisor.stop({ killGraceMs: 500 })).resolves.toEqual({
status: "verified-cleanup",
});
// Cleanup must be attempted. The exact attempt count is an internal
// retry ladder, so it is deliberately not pinned here.
expect(cleanup).toHaveBeenCalled();
expect(directSignal).not.toHaveBeenCalled();
} finally {
directSignal.mockRestore();
await stopProviderProcessFixture(child);
}
});
it("cleans an owned group even after its launcher leader has exited", async () => {