diff --git a/CHANGELOG.md b/CHANGELOG.md index 89c5d7c40..9aaa44bc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Docs: https://docs.openclaw.ai ### Fixes - Telegram: pass `parentPeer` for forum topic binding inheritance so group-level bindings apply to all topics within the group. (#9789, fixes #9545, #9351) +- CLI: pass `--disable-warning=ExperimentalWarning` as a Node CLI option when respawning (avoid disallowed `NODE_OPTIONS` usage; fixes npm pack). (#9691) Thanks @18-RAJAT. - CLI: resolve bundled Chrome extension assets by walking up to the nearest assets directory; add resolver and clipboard tests. (#8914) Thanks @kelvinCB. - Tests: stabilize Windows ACL coverage with deterministic os.userInfo mocking. (#9335) Thanks @M00N7682. - Heartbeat: allow explicit accountId routing for multi-account channels. (#8702) Thanks @lsh411. diff --git a/src/entry.ts b/src/entry.ts index d58bbae28..bbf2173a3 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -18,11 +18,17 @@ if (process.argv.includes("--no-color")) { const EXPERIMENTAL_WARNING_FLAG = "--disable-warning=ExperimentalWarning"; -function hasExperimentalWarningSuppressed(nodeOptions: string): boolean { - if (!nodeOptions) { - return false; +function hasExperimentalWarningSuppressed(): boolean { + const nodeOptions = process.env.NODE_OPTIONS ?? ""; + if (nodeOptions.includes(EXPERIMENTAL_WARNING_FLAG) || nodeOptions.includes("--no-warnings")) { + return true; } - return nodeOptions.includes(EXPERIMENTAL_WARNING_FLAG) || nodeOptions.includes("--no-warnings"); + for (const arg of process.execArgv) { + if (arg === EXPERIMENTAL_WARNING_FLAG || arg === "--no-warnings") { + return true; + } + } + return false; } function ensureExperimentalWarningSuppressed(): boolean { @@ -32,18 +38,21 @@ function ensureExperimentalWarningSuppressed(): boolean { if (isTruthyEnvValue(process.env.OPENCLAW_NODE_OPTIONS_READY)) { return false; } - const nodeOptions = process.env.NODE_OPTIONS ?? ""; - if (hasExperimentalWarningSuppressed(nodeOptions)) { + if (hasExperimentalWarningSuppressed()) { return false; } + // Respawn guard (and keep recursion bounded if something goes wrong). process.env.OPENCLAW_NODE_OPTIONS_READY = "1"; - process.env.NODE_OPTIONS = `${nodeOptions} ${EXPERIMENTAL_WARNING_FLAG}`.trim(); - - const child = spawn(process.execPath, [...process.execArgv, ...process.argv.slice(1)], { - stdio: "inherit", - env: process.env, - }); + // Pass flag as a Node CLI option, not via NODE_OPTIONS (--disable-warning is disallowed in NODE_OPTIONS). + const child = spawn( + process.execPath, + [EXPERIMENTAL_WARNING_FLAG, ...process.execArgv, ...process.argv.slice(1)], + { + stdio: "inherit", + env: process.env, + }, + ); attachChildProcessBridge(child);