fix(apple): preserve asset catalog caller cancellation reason (#6055)

* fix(apple): preserve asset catalog caller cancellation reason

* test(apple): cover asset catalog cancellation checkpoints
This commit is contained in:
Shakti authored and GitHub committed 2026-10-22 02:51:11 +08:00
1 parent 0583fc69be
commit 07fd426e9a
2 files changed
+142 -1

No files matched your search

@@ -12,12 +12,19 @@ import {
parseAppleAssetCatalogRecords,
projectAppleAssetCatalogPage,
} from "../../domain/apple/appleAssetCatalog.js";
import { execFileOutput } from "../../process/ExecFileOutput.js";
import {
ExecFileOutputCancelledError,
execFileOutput,
} from "../../process/ExecFileOutput.js";
const ASSETUTIL = "/usr/bin/assetutil";
const MAX_CATALOG_BYTES = 64 * 1024 * 1024;
const MAX_TOTAL_METADATA_BYTES = 64 * 1024 * 1024;
/** The command owner wraps the exact caller reason; do not replace it with the wrapper. */
const cancellationCause = (cause: unknown, signal?: AbortSignal): unknown =>
cause instanceof ExecFileOutputCancelledError ? cause.cause : signal?.reason;
/** Inspect compiled asset catalog metadata without extracting rendition bytes. */
export const analyzeAppleAssetCatalogs = async (input: {
readonly bundlePath: string;
@@ -275,6 +282,7 @@ const runAssetUtil = async (
throw new ArtifactReaderFailure(
"cancelled",
"Asset catalog inspection cancelled",
{ cause: cancellationCause(cause, signal) },
);
const code =
typeof cause === "object" && cause !== null && "code" in cause
@@ -310,6 +318,7 @@ const digestBounded = async (
throw new ArtifactReaderFailure(
"cancelled",
"Asset catalog inspection cancelled",
{ cause: signal.reason },
);
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
length += bytes.length;