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
+2 -1
View File
@@ -1,3 +1,4 @@
import type { Stats } from "node:fs";
import type { FileHandle } from "node:fs/promises";
import { ArtifactReaderFailure } from "./ArtifactReader.js";
@@ -7,7 +8,7 @@ export const MAX_ASAR_HEADER_BYTES = 16 * 1024 * 1024;
/** Admit both Chromium pickle extents before an upstream decoder allocates them. */
export const admitAsarHeader = async (
handle: FileHandle,
handle: Pick<FileHandle, "read"> & { stat(): Promise<Stats> },
): Promise<{
readonly archiveBytes: number;
readonly headerBytes: number;