perf: reduce status json startup memory

This commit is contained in:
Ayaan Zaidi
2026-03-16 21:50:16 +05:30
parent 2c3c48fd8d
commit 97a7dcf48e
12 changed files with 599 additions and 62 deletions

View File

@@ -1,12 +1,10 @@
import process from "node:process";
import { fileURLToPath } from "node:url";
import { loadDotEnv } from "../infra/dotenv.js";
import { normalizeEnv } from "../infra/env.js";
import { formatUncaughtError } from "../infra/errors.js";
import { isMainModule } from "../infra/is-main.js";
import { ensureOpenClawCliOnPath } from "../infra/path-env.js";
import { assertSupportedRuntime } from "../infra/runtime-guard.js";
import { installUnhandledRejectionHandler } from "../infra/unhandled-rejections.js";
import { enableConsoleCapture } from "../logging.js";
import {
getCommandPathWithRootOptions,
@@ -14,6 +12,7 @@ import {
hasHelpOrVersion,
isRootHelpInvocation,
} from "./argv.js";
import { loadCliDotEnv } from "./dotenv.js";
import { applyCliProfileEnv, parseCliProfileArgs } from "./profile.js";
import { tryRouteCli } from "./route.js";
import { normalizeWindowsArgv } from "./windows-argv.js";
@@ -91,7 +90,7 @@ export async function runCli(argv: string[] = process.argv) {
}
normalizedArgv = parsedProfile.argv;
loadDotEnv({ quiet: true });
loadCliDotEnv({ quiet: true });
normalizeEnv();
if (shouldEnsureCliPath(normalizedArgv)) {
ensureOpenClawCliOnPath();
@@ -116,6 +115,7 @@ export async function runCli(argv: string[] = process.argv) {
const { buildProgram } = await import("./program.js");
const program = buildProgram();
const { installUnhandledRejectionHandler } = await import("../infra/unhandled-rejections.js");
// Global error handlers to prevent silent crashes from unhandled rejections/exceptions.
// These log the error and exit gracefully instead of crashing without trace.