Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bin/nemoclaw.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ if (invokedAs === "nemo-deepagents") {
process.env.NEMOCLAW_INVOKED_AS = "nemo-deepagents";
}

require("../dist/nemoclaw");
const { log } = require("../dist/lib/cli/logger");
const { mainPromise } = require("../dist/nemoclaw");
mainPromise.catch((error) => {
const message = error instanceof Error ? error.message : String(error);
log.error(`Error: ${message}`);
process.exitCode = 1;
});
39 changes: 39 additions & 0 deletions test/package-contract/cli/top-level-error.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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 REPO_ROOT = path.join(import.meta.dirname, "../../..");
const cliPath = JSON.stringify(path.join(REPO_ROOT, "bin", "nemoclaw.js"));
const dispatchPath = JSON.stringify(
path.join(REPO_ROOT, "dist", "lib", "cli", "public-dispatch.js"),
);

describe("compiled CLI top-level errors", () => {
it("prints one error line without an uncaught Node.js stack (#8202)", () => {
const result = spawnSync(
process.execPath,
[
"--eval",
`const path = ${dispatchPath};
require.cache[path] = {
loaded: true,
exports: { dispatchCli: () => Promise.reject(new Error("Command failed.")) },
};
require(${cliPath});`,
],
{
cwd: REPO_ROOT,
encoding: "utf-8",
env: { ...process.env, NEMOCLAW_DISABLE_AUTO_DISPATCH: "0" },
},
);

expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr).toBe("Error: Command failed.\n");
expect(result.stderr).not.toMatch(/\n\s+at |Node\.js v/);
});
});
Loading