diff --git a/bin/nemoclaw.js b/bin/nemoclaw.js index 46cdad20d0e..dedf6ae25e4 100755 --- a/bin/nemoclaw.js +++ b/bin/nemoclaw.js @@ -9,6 +9,19 @@ if (invokedAs === "nemo-deepagents") { process.env.NEMOCLAW_INVOKED_AS = "nemo-deepagents"; } +// `node:sqlite` is still experimental on Node 22, which prints an ExperimentalWarning on +// stderr for every command that opens the state store and breaks `VER=$(nemoclaw +// --version)`-style scripts (#12741). Drop only that warning; all others still print. +const emitWarning = process.emitWarning; +process.emitWarning = function (warning, ...args) { + const type = typeof args[0] === "string" ? args[0] : args[0]?.type; + const message = warning instanceof Error ? warning.message : String(warning); + if (type === "ExperimentalWarning" && message.startsWith("SQLite is an experimental feature")) { + return; + } + return emitWarning.call(this, warning, ...args); +}; + let topLevelLog = null; const PORT_ENV_NAME = diff --git a/test/package-contract/cli/launcher-warnings.test.ts b/test/package-contract/cli/launcher-warnings.test.ts new file mode 100644 index 00000000000..053b35cc470 --- /dev/null +++ b/test/package-contract/cli/launcher-warnings.test.ts @@ -0,0 +1,33 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { spawnSync } from "node:child_process"; +import path from "node:path"; + +import { describe, expect, it } from "vitest"; + +const LAUNCHER = path.join(import.meta.dirname, "..", "..", "..", "bin", "nemoclaw.js"); + +describe("CLI launcher warnings (#12741)", () => { + it("drops only the node:sqlite ExperimentalWarning", () => { + // Emit the warnings after the launcher installs its filter, so the result does not + // depend on whether this Node version still marks node:sqlite as experimental. + const script = ` + process.argv = [process.execPath, ${JSON.stringify(LAUNCHER)}, "--version"]; + require(${JSON.stringify(LAUNCHER)}); + process.emitWarning("SQLite is an experimental feature and might change at any time", "ExperimentalWarning"); + process.emitWarning("another experimental feature", "ExperimentalWarning"); + process.emitWarning("a deprecated feature", "DeprecationWarning"); + `; + const result = spawnSync(process.execPath, ["-e", script], { + encoding: "utf8", + env: { ...process.env, NEMOCLAW_GATEWAY_PORT: "8080" }, + }); + + expect(result.status, result.stderr).toBe(0); + expect(result.stdout).toMatch(/^nemoclaw v/); + expect(result.stderr).not.toContain("SQLite is an experimental feature"); + expect(result.stderr).toContain("ExperimentalWarning: another experimental feature"); + expect(result.stderr).toContain("DeprecationWarning: a deprecated feature"); + }, 15_000); +});