Files
rea/src/process/DarwinProcessRunTokenReader.timeout.test.ts
T
d8a9673fc4 fix(process): name the Swift compile deadline (#6071)
Name REA_SWIFTC_COMPILE_TIMEOUT_MS, its effective milliseconds, the
1..2147483647 range, and the omitted 120000 ms default when a Darwin
ownership-helper compile times out. A change applies after REA restarts,
on the next ownership-helper compile.

Producer SIGXCPU and SIGXFSZ recovery says REA retains the tighter
inherited limit. Agent-visible fixed caps in this theme say this release
has no runtime override. Numbers are unchanged.

Refs #5910

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: morluto <morluto@users.noreply.github.com>
2026-10-21 23:46:29 +08:00

49 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
resolveSwiftcCompileTimeoutMs,
swiftcCompileTimeoutRecovery,
} from "./DarwinProcessRunTokenReader.js";
import { MAX_PROVIDER_STARTUP_TIMEOUT_MS } from "../config/providerStartupTimeout.js";
describe("resolveSwiftcCompileTimeoutMs", () => {
it("keeps the historical default when unset", () => {
expect(resolveSwiftcCompileTimeoutMs({ environment: {} })).toBe(120_000);
});
it("prefers an explicit compileTimeoutMs over the environment", () => {
expect(
resolveSwiftcCompileTimeoutMs({
compileTimeoutMs: 12_000,
environment: { REA_SWIFTC_COMPILE_TIMEOUT_MS: "300000" },
}),
).toBe(12_000);
});
it("reads a valid REA_SWIFTC_COMPILE_TIMEOUT_MS value", () => {
expect(
resolveSwiftcCompileTimeoutMs({
environment: { REA_SWIFTC_COMPILE_TIMEOUT_MS: "300000" },
}),
).toBe(300_000);
});
it("falls back to the default for a malformed environment value", () => {
expect(
resolveSwiftcCompileTimeoutMs({
environment: { REA_SWIFTC_COMPILE_TIMEOUT_MS: "loud" },
}),
).toBe(120_000);
});
it("names the launch-environment deadline, range, and restart on a timeout", () => {
const recovery = swiftcCompileTimeoutRecovery(300_000);
expect(recovery).toContain("REA_SWIFTC_COMPILE_TIMEOUT_MS");
expect(recovery).toContain("300000 ms");
expect(recovery).toContain(`1..${String(MAX_PROVIDER_STARTUP_TIMEOUT_MS)}`);
expect(recovery).toContain("120000 ms");
expect(recovery).toContain("restart REA");
expect(recovery).toContain("next ownership-helper compile");
});
});