@@ -7,12 +7,10 @@ import { setTimeout as delay } from "node:timers/promises";
77import { pathToFileURL } from "node:url" ;
88import { promisify } from "node:util" ;
99import type { GatewayRpcClient } from "./mcp-channels-harness.ts" ;
10+ import { readPositiveIntEnv } from "./lib/env-limits.mjs" ;
1011
1112const execFileAsync = promisify ( execFile ) ;
12- const PROBE_PID_WAIT_MS = readPositiveInt (
13- process . env . OPENCLAW_CRON_MCP_CLEANUP_PID_WAIT_MS ,
14- 120_000 ,
15- ) ;
13+ const PROBE_PID_WAIT_MS = readCronMcpCleanupProbePidWaitMs ( ) ;
1614type McpChannelsHarness = typeof import ( "./mcp-channels-harness.ts" ) ;
1715let mcpChannelsHarness : McpChannelsHarness | undefined ;
1816
@@ -25,13 +23,8 @@ async function loadMcpChannelsHarness(): Promise<McpChannelsHarness> {
2523 return mcpChannelsHarness ;
2624}
2725
28- function readPositiveInt ( raw : string | undefined , fallback : number ) : number {
29- const text = ( raw ?? "" ) . trim ( ) ;
30- if ( ! / ^ \d + $ / u. test ( text ) ) {
31- return fallback ;
32- }
33- const parsed = Number ( text ) ;
34- return Number . isInteger ( parsed ) && parsed > 0 ? parsed : fallback ;
26+ export function readCronMcpCleanupProbePidWaitMs ( env : NodeJS . ProcessEnv = process . env ) : number {
27+ return readPositiveIntEnv ( "OPENCLAW_CRON_MCP_CLEANUP_PID_WAIT_MS" , 120_000 , env ) ;
3528}
3629
3730async function readProbePid ( pidPath : string ) : Promise < number | undefined > {
0 commit comments