Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
fix(cli): don't read IX_MAP_DEADLINE_MS=15m as 15 milliseconds
KageBinaryf11acaeef316
diff --git a/ix-cli/src/cli/__tests__/env-durations.test.ts b/ix-cli/src/cli/__tests__/env-durations.test.tsnew file mode 100644index 00000000..bb510516--- /dev/null+++ b/ix-cli/src/cli/__tests__/env-durations.test.ts@@ -0,0 +1,45 @@+// Copyright 2026 Ix Infrastructure Inc.++import { afterEach, describe, expect, it } from "vitest";+import { parsePositiveIntEnv } from "../commands/ingest.js";+import { mapDeadlineMs } from "../commands/map.js";++// `Number.parseInt` reads any numeric prefix, so a unit suffix or an exponent+// silently became a tiny number: IX_MAP_DEADLINE_MS=15m aborted every map+// after 15 ms, and IX_COMMIT_HTTP_MAX_FILES=1e3 sent one file per request.+describe("mapDeadlineMs", () => {+ it("defaults to 15 minutes when unset", () => {+ expect(mapDeadlineMs(undefined)).toBe(15 * 60 * 1000);+ });++ it("takes a plain number of milliseconds", () => {+ expect(mapDeadlineMs("60000")).toBe(60_000);+ });++ it("is disabled by 0 or an empty value", () => {+ expect(mapDeadlineMs("0")).toBeUndefined();+ expect(mapDeadlineMs("")).toBeUndefined();+ });++ it("keeps the default for a value with a unit rather than reading its prefix", () => {+ expect(mapDeadlineMs("15m")).toBe(15 * 60 * 1000);+ expect(mapDeadlineMs("1e3")).toBe(15 * 60 * 1000);+ });+});++describe("parsePositiveIntEnv", () => {+ const name = "IX_TEST_POSITIVE_INT_ENV";+ afterEach(() => { delete process.env[name]; });++ it("reads a plain positive integer", () => {+ process.env[name] = "250";+ expect(parsePositiveIntEnv(name, 7)).toBe(250);+ });++ it("falls back for a value with a suffix or exponent", () => {+ for (const raw of ["1e3", "2k", "10ms", "-5", "0"]) {+ process.env[name] = raw;+ expect(parsePositiveIntEnv(name, 7), raw).toBe(7);+ }+ });+});diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.tsindex f1af2ea3..461c2e7b 100644--- a/ix-cli/src/cli/commands/ingest.ts+++ b/ix-cli/src/cli/commands/ingest.ts@@ -168,9 +168,12 @@ const MINIFIED_AVG_LINE_THRESHOLD = 2_000;const SLOW_WORK_LOG_MS = 5_000;const SLOW_WORK_REPEAT_MS = 10_000;-function parsePositiveIntEnv(name: string, fallback: number): number {- const raw = process.env[name];+export function parsePositiveIntEnv(name: string, fallback: number): number {+ const raw = process.env[name]?.trim();if (!raw) return fallback;+ // Matched, not parsed, as in single-flight's lockMaxMs: `parseInt` reads any+ // numeric prefix, so `1e3` meant 1 and `2k` meant 2.+ if (!/^\d+$/.test(raw)) return fallback;const parsed = Number.parseInt(raw, 10);return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;}diff --git a/ix-cli/src/cli/commands/map.ts b/ix-cli/src/cli/commands/map.tsindex 05ab5a42..78ca3aea 100644--- a/ix-cli/src/cli/commands/map.ts+++ b/ix-cli/src/cli/commands/map.ts@@ -25,11 +25,22 @@ import { readBackendHealth } from "./upgrade.js";// via IX_MAP_DEADLINE_MS; 0 disables the budget.const DEFAULT_MAP_DEADLINE_MS = 15 * 60 * 1000;-function mapDeadlineSignal(): AbortSignal | undefined {- const raw = process.env.IX_MAP_DEADLINE_MS;- const budget = raw !== undefined ? Number.parseInt(raw, 10) : DEFAULT_MAP_DEADLINE_MS;+/** The map budget in ms, or undefined when disabled. */+export function mapDeadlineMs(raw = process.env.IX_MAP_DEADLINE_MS): number | undefined {+ if (raw === undefined) return DEFAULT_MAP_DEADLINE_MS;+ const trimmed = raw.trim();+ // Matched, not parsed: `parseInt("15m")` is 15, a 15 ms budget that aborted+ // every request of every map. A value that is not a plain number of ms keeps+ // the default; empty and 0 keep disabling it, as they did.+ if (trimmed !== "" && !/^\d+$/.test(trimmed)) return DEFAULT_MAP_DEADLINE_MS;+ const budget = Number.parseInt(trimmed, 10);if (!Number.isFinite(budget) || budget <= 0) return undefined; // disabled- return AbortSignal.timeout(budget);+ return budget;+}++function mapDeadlineSignal(): AbortSignal | undefined {+ const budget = mapDeadlineMs();+ return budget === undefined ? undefined : AbortSignal.timeout(budget);}// Whether an automatically-triggered map should be skipped. Background refresh