CLI: reduce startup overhead for health and status --json#30940
CLI: reduce startup overhead for health and status --json#30940vincentkoc merged 22 commits intoopenclaw:mainfrom
Conversation
|
Fixed the two failing checks on latest head (
Validation run locally:
|
|
Related prior work: #27973 by @lupuletic covers the same startup problem space and informed this iteration. This PR currently carries the subset we validated end-to-end here (route/preload changes, |
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🔵 Environment-controlled Node compile cache enabled at startup (unsafe when run with elevated privileges)
Description
Security impact (local):
Vulnerable code: normalizeEnv();
if (!isTruthyEnvValue(process.env.NODE_DISABLE_COMPILE_CACHE)) {
try {
enableCompileCache();
} catch {
// Best-effort only; never block startup.
}
}Related documentation change (risk amplifier): recommending export NODE_COMPILE_CACHE=/var/tmp/openclaw-compile-cache
mkdir -p /var/tmp/openclaw-compile-cacheRecommendationTreat the compile cache directory as a security boundary when privileges may differ. Code mitigations (recommended):
import { enableCompileCache } from "node:module";
const isRoot = typeof process.getuid === "function" && process.getuid() === 0;
if (isRoot) {
// Avoid honoring attacker-controlled cache paths when privileged.
// Either disable entirely:
process.env.NODE_DISABLE_COMPILE_CACHE = "1";
// or at least ignore any externally provided location:
delete process.env.NODE_COMPILE_CACHE;
}
if (!isTruthyEnvValue(process.env.NODE_DISABLE_COMPILE_CACHE)) {
enableCompileCache();
}
Documentation mitigations:
Analyzed PR: #30940 at commit Last updated on: 2026-03-01T21:28:44Z |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5e0902cc2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryImplements comprehensive CLI startup performance optimizations:
The implementation properly handles dependencies between async operations, maintains type safety, and includes appropriate test coverage. Error handling uses try-catch where needed to ensure resilience. Confidence Score: 5/5
Last reviewed commit: b3cfcc0 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7653bce241
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const routeHealth: RouteSpec = { | ||
| match: (path) => path[0] === "health", | ||
| loadPlugins: true, | ||
| run: async (argv) => { |
There was a problem hiding this comment.
Restore plugin preload for routed health command
The fast-route now runs health without preloading plugins, but prepareRoutedCommand only initializes the registry when loadPlugins is set, and healthCommand relies on listChannelPlugins() for channel-account fallback selection and linked-channel logSelfId output. On the default route-first path this leaves the registry empty, so openclaw health can silently omit channel-specific diagnostics that were previously shown.
Useful? React with 👍 / 👎.
Summary
status --jsonskips plugin preloadinghealthfast-routescanStatuswhen--jsonis used--version/-V/-vbypasses full CLI bootstrapstatus --jsonsecurity audit with status scan workmodule.enableCompileCache()with safe no-throw behaviorNODE_COMPILE_CACHE,OPENCLAW_NO_RESPAWN)Testing
pnpm tsgopnpm test src/commands/status.test.ts src/cli/argv.test.ts src/cli/program/routes.test.tspnpm buildBenchmark Snapshot (local)
node dist/entry.js --version: ~1025ms -> ~89ms averagenode dist/entry.js status --json: ~4913ms -> ~3787ms averagenode dist/entry.js status: ~6939ms -> ~5914ms averageFixes: #5871