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
parent
679bb087db
commit
ea237115a9
|
|
@ -26,6 +26,7 @@ Docs: https://docs.openclaw.ai
|
||||||
### Fixes
|
### Fixes
|
||||||
|
|
||||||
- Telegram: pass `parentPeer` for forum topic binding inheritance so group-level bindings apply to all topics within the group. (#9789, fixes #9545, #9351)
|
- 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.
|
- 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.
|
- 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.
|
- Heartbeat: allow explicit accountId routing for multi-account channels. (#8702) Thanks @lsh411.
|
||||||
|
|
|
||||||
33
src/entry.ts
33
src/entry.ts
|
|
@ -18,11 +18,17 @@ if (process.argv.includes("--no-color")) {
|
||||||
|
|
||||||
const EXPERIMENTAL_WARNING_FLAG = "--disable-warning=ExperimentalWarning";
|
const EXPERIMENTAL_WARNING_FLAG = "--disable-warning=ExperimentalWarning";
|
||||||
|
|
||||||
function hasExperimentalWarningSuppressed(nodeOptions: string): boolean {
|
function hasExperimentalWarningSuppressed(): boolean {
|
||||||
if (!nodeOptions) {
|
const nodeOptions = process.env.NODE_OPTIONS ?? "";
|
||||||
return false;
|
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 {
|
function ensureExperimentalWarningSuppressed(): boolean {
|
||||||
|
|
@ -32,18 +38,21 @@ function ensureExperimentalWarningSuppressed(): boolean {
|
||||||
if (isTruthyEnvValue(process.env.OPENCLAW_NODE_OPTIONS_READY)) {
|
if (isTruthyEnvValue(process.env.OPENCLAW_NODE_OPTIONS_READY)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const nodeOptions = process.env.NODE_OPTIONS ?? "";
|
if (hasExperimentalWarningSuppressed()) {
|
||||||
if (hasExperimentalWarningSuppressed(nodeOptions)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Respawn guard (and keep recursion bounded if something goes wrong).
|
||||||
process.env.OPENCLAW_NODE_OPTIONS_READY = "1";
|
process.env.OPENCLAW_NODE_OPTIONS_READY = "1";
|
||||||
process.env.NODE_OPTIONS = `${nodeOptions} ${EXPERIMENTAL_WARNING_FLAG}`.trim();
|
// Pass flag as a Node CLI option, not via NODE_OPTIONS (--disable-warning is disallowed in NODE_OPTIONS).
|
||||||
|
const child = spawn(
|
||||||
const child = spawn(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
|
process.execPath,
|
||||||
stdio: "inherit",
|
[EXPERIMENTAL_WARNING_FLAG, ...process.execArgv, ...process.argv.slice(1)],
|
||||||
env: process.env,
|
{
|
||||||
});
|
stdio: "inherit",
|
||||||
|
env: process.env,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
attachChildProcessBridge(child);
|
attachChildProcessBridge(child);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue