diff --git a/scripts/check-cli-startup-memory.mjs b/scripts/check-cli-startup-memory.mjs index 3520bd0dff7..97267f6ae2c 100644 --- a/scripts/check-cli-startup-memory.mjs +++ b/scripts/check-cli-startup-memory.mjs @@ -20,7 +20,7 @@ let rssHookPath = null; function readPositiveIntEnv(name, fallback, env = process.env) { const value = readPositiveNumberEnv(name, fallback, env); - if (!Number.isInteger(value)) { + if (!Number.isSafeInteger(value)) { throw new Error(`${name} must be a positive integer`); } return value; diff --git a/test/scripts/check-cli-startup-memory.test.ts b/test/scripts/check-cli-startup-memory.test.ts index 8ea07c4e07c..81e0e7972f8 100644 --- a/test/scripts/check-cli-startup-memory.test.ts +++ b/test/scripts/check-cli-startup-memory.test.ts @@ -86,6 +86,11 @@ describe("check-cli-startup-memory", () => { OPENCLAW_STARTUP_MEMORY_TIMEOUT_MS: "1000.5", }), ).toThrow("OPENCLAW_STARTUP_MEMORY_TIMEOUT_MS must be a positive integer"); + expect(() => + testing.readPositiveIntEnv("OPENCLAW_STARTUP_MEMORY_TIMEOUT_MS", 60_000, { + OPENCLAW_STARTUP_MEMORY_TIMEOUT_MS: String(Number.MAX_SAFE_INTEGER + 1), + }), + ).toThrow("OPENCLAW_STARTUP_MEMORY_TIMEOUT_MS must be a positive integer"); expect( testing.readPositiveIntEnv("OPENCLAW_STARTUP_MEMORY_TIMEOUT_MS", 60_000, { OPENCLAW_STARTUP_MEMORY_TIMEOUT_MS: "1000",