fix(cli): avoid NODE_OPTIONS for --disable-warning (#9691) (thanks @18-RAJAT)

Fixes npm pack failing on modern Node where --disable-warning is disallowed in NODE_OPTIONS.
main
Rajat Joshi 2026-02-06 01:35:14 +05:30 committed by GitHub
parent 679bb087db
commit ea237115a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 12 deletions

View File

@ -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.

View File

@ -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);