


















11import fs from "node:fs";
22import os from "node:os";
33import { describe, expect, it, vi } from "vitest";
4+import { MAX_TIMER_TIMEOUT_MS } from "../shared/number-coercion.js";
45import {
56getShellEnvAppliedKeys,
67getShellPathFromLoginShell,
@@ -155,6 +156,32 @@ describe("shell env fallback", () => {
155156OPENCLAW_SHELL_ENV_TIMEOUT_MS: "42abc",
156157}),
157158).toBe(15000);
159+expect(
160+resolveShellEnvFallbackTimeoutMs({
161+OPENCLAW_SHELL_ENV_TIMEOUT_MS: String(Number.MAX_SAFE_INTEGER),
162+}),
163+).toBe(MAX_TIMER_TIMEOUT_MS);
164+});
165+166+it("caps oversized fallback exec timeouts before probing the login shell", () => {
167+resetShellPathCacheForTests();
168+const env: NodeJS.ProcessEnv = {};
169+let receivedTimeout: number | undefined;
170+const exec = vi.fn((_shell: string, _args: string[], options: { timeout?: number }) => {
171+receivedTimeout = options.timeout;
172+return Buffer.from("OPENAI_API_KEY=from-shell\0");
173+});
174+175+const res = loadShellEnvFallback({
176+enabled: true,
177+ env,
178+expectedKeys: ["OPENAI_API_KEY"],
179+timeoutMs: Number.MAX_SAFE_INTEGER,
180+exec: exec as unknown as Parameters<typeof loadShellEnvFallback>[0]["exec"],
181+});
182+183+expect(res.ok).toBe(true);
184+expect(receivedTimeout).toBe(MAX_TIMER_TIMEOUT_MS);
158185});
159186160187it("skips when already has all expected keys", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。