fix(process): avoid cold ownership helper deadline exhaustion (#1139)

* fix(process): avoid cold ownership helper deadline exhaustion

Fixes #1137.

* test(process): fix cold ownership test deadlines and cleanup

* fix(process): isolate Swift cache overrides and retain diagnostics

* test(electron): assert blank path rejection without trim assumptions

---------

Co-authored-by: Chris <Chis@RICH-13918M.local>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-10-09 07:18:07 +08:00
1 parent 4034883e98
commit 65a809a0da
6 files changed
+156 -16

No files matched your search

+8 -9
View File
@@ -149,21 +149,18 @@ export const createDarwinProcessRunTokenReader = (
exitCleanupInstalled = true;
if (signal.aborted || closed) throw abortReason(signal);
const output = join(operationRoot, "reader");
const compilerEnvironment = { ...process.env };
// Use Swift's reusable default cache for REA's internal helper compilation.
delete compilerEnvironment.CLANG_MODULE_CACHE_PATH;
try {
await execFileOutput(
options.xcrun ?? "/usr/bin/xcrun",
[
"swiftc",
"-module-cache-path",
join(operationRoot, "modules"),
...sourceFiles,
"-o",
output,
],
["swiftc", ...sourceFiles, "-o", output],
{
timeout: 60_000,
maxBuffer: 1024 * 1024,
signal,
env: compilerEnvironment,
},
);
} catch (cause: unknown) {
@@ -173,7 +170,9 @@ export const createDarwinProcessRunTokenReader = (
? String(cause.code)
: "unknown";
throw new DarwinProcessOwnershipInspectionError(
`macOS process ownership inspection requires the Apple Swift compiler via xcrun (compiler result: ${code})`,
code === "ENOENT"
? `macOS process ownership inspection requires the Apple Swift compiler via xcrun (compiler result: ${code})`
: `macOS process ownership helper compilation failed via xcrun (compiler result: ${code}): ${cause instanceof Error ? cause.message : String(cause)}`,
{ cause },
);
}