Skip to content

Commit 715e324

Browse files
authored
refactor(cli): remove unsupported Node 24 cache workaround (#124271)
1 parent 8f807ae commit 715e324

3 files changed

Lines changed: 5 additions & 142 deletions

File tree

‎src/entry.compile-cache.test-support.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import "./entry.compile-cache.js";
55
type CompileCacheParams = {
66
env?: NodeJS.ProcessEnv;
77
installRoot: string;
8-
nodeVersion?: string;
9-
platform?: NodeJS.Platform;
108
};
119

1210
type CompileCacheRespawnPlan = {
@@ -25,7 +23,6 @@ type CompileCacheTestApi = {
2523
installRoot: string;
2624
argv?: string[];
2725
compileCacheDir?: string;
28-
nodeVersion?: string;
2926
platform?: NodeJS.Platform;
3027
}): CompileCacheRespawnPlan | undefined;
3128
isSourceCheckoutInstallRoot(installRoot: string): boolean;

‎src/entry.compile-cache.test.ts‎

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,12 @@ describe("entry compile cache", () => {
5858
shouldEnableOpenClawCompileCache({
5959
env: {},
6060
installRoot: root,
61-
nodeVersion: "24.15.0",
62-
platform: "win32",
6361
}),
6462
).toBe(true);
6563
expect(
6664
shouldEnableOpenClawCompileCache({
6765
env: { NODE_DISABLE_COMPILE_CACHE: "1" },
6866
installRoot: root,
69-
nodeVersion: "24.15.0",
70-
platform: "win32",
7167
}),
7268
).toBe(false);
7369
});
@@ -204,46 +200,18 @@ describe("entry compile cache", () => {
204200
expect(plan?.detachForProcessTree).toBe(false);
205201
});
206202

207-
it("does not respawn unaffected packaged installs when NODE_COMPILE_CACHE is configured", () => {
203+
it("does not respawn packaged installs when NODE_COMPILE_CACHE is configured", () => {
208204
const root = tempDirs.make("openclaw-compile-cache-package-respawn-");
209205

210206
expect(
211207
buildOpenClawCompileCacheRespawnPlan({
212208
currentFile: path.join(root, "dist", "entry.js"),
213209
env: { NODE_COMPILE_CACHE: "/tmp/openclaw-cache" },
214210
installRoot: root,
215-
nodeVersion: "24.1.0",
216-
platform: "linux",
217211
}),
218212
).toBeUndefined();
219213
});
220214

221-
it("builds a no-cache respawn plan for affected Windows packaged installs", () => {
222-
const root = tempDirs.make("openclaw-compile-cache-package-win24-");
223-
const entryFile = path.join(root, "dist", "entry.js");
224-
225-
const plan = buildOpenClawCompileCacheRespawnPlan({
226-
currentFile: entryFile,
227-
env: { NODE_COMPILE_CACHE: "/tmp/openclaw-cache" },
228-
execArgv: ["--no-warnings"],
229-
execPath: "/usr/bin/node",
230-
installRoot: root,
231-
argv: ["/usr/bin/node", entryFile, "doctor", "--fix", "--non-interactive"],
232-
nodeVersion: "24.1.0",
233-
platform: "win32",
234-
});
235-
236-
expect(plan).toEqual({
237-
command: "/usr/bin/node",
238-
args: ["--no-warnings", entryFile, "doctor", "--fix", "--non-interactive"],
239-
env: {
240-
NODE_DISABLE_COMPILE_CACHE: "1",
241-
OPENCLAW_COMPILE_CACHE_DISABLED_RESPAWNED: "1",
242-
},
243-
detachForProcessTree: false,
244-
});
245-
});
246-
247215
it("does not respawn source checkouts twice", async () => {
248216
const root = tempDirs.make("openclaw-compile-cache-respawn-once-");
249217
await fs.mkdir(path.join(root, "src"), { recursive: true });
@@ -376,72 +344,4 @@ describe("entry compile cache", () => {
376344
vi.useRealTimers();
377345
}
378346
});
379-
380-
it("disables compile cache for early Node 24.x versions on Windows", () => {
381-
const root = tempDirs.make("openclaw-compile-cache-node24-");
382-
expect(
383-
shouldEnableOpenClawCompileCache({
384-
env: {},
385-
installRoot: root,
386-
nodeVersion: "24.1.0",
387-
platform: "win32",
388-
}),
389-
).toBe(false);
390-
expect(
391-
shouldEnableOpenClawCompileCache({
392-
env: {},
393-
installRoot: root,
394-
nodeVersion: "24.14.0",
395-
platform: "win32",
396-
}),
397-
).toBe(false);
398-
});
399-
400-
it("keeps compile cache enabled for early Node 24.x on non-Windows packaged installs", () => {
401-
const root = tempDirs.make("openclaw-compile-cache-node24-nonwin-");
402-
expect(
403-
shouldEnableOpenClawCompileCache({
404-
env: {},
405-
installRoot: root,
406-
nodeVersion: "24.1.0",
407-
platform: "linux",
408-
}),
409-
).toBe(true);
410-
expect(
411-
shouldEnableOpenClawCompileCache({
412-
env: {},
413-
installRoot: root,
414-
nodeVersion: "24.14.0",
415-
platform: "darwin",
416-
}),
417-
).toBe(true);
418-
});
419-
420-
it("keeps compile cache enabled for Node 24.15+ and other majors on Windows", () => {
421-
const root = tempDirs.make("openclaw-compile-cache-node2415-");
422-
expect(
423-
shouldEnableOpenClawCompileCache({
424-
env: {},
425-
installRoot: root,
426-
nodeVersion: "24.15.0",
427-
platform: "win32",
428-
}),
429-
).toBe(true);
430-
expect(
431-
shouldEnableOpenClawCompileCache({
432-
env: {},
433-
installRoot: root,
434-
nodeVersion: "22.22.0",
435-
platform: "win32",
436-
}),
437-
).toBe(true);
438-
expect(
439-
shouldEnableOpenClawCompileCache({
440-
env: {},
441-
installRoot: root,
442-
nodeVersion: "25.0.0",
443-
platform: "win32",
444-
}),
445-
).toBe(true);
446-
});
447347
});

‎src/entry.compile-cache.ts‎

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { enableCompileCache, getCompileCacheDir } from "node:module";
55
import os from "node:os";
66
import path from "node:path";
77
import process from "node:process";
8-
import { expectDefined } from "@openclaw/normalization-core";
98
import {
109
isTerminalInteractiveRespawnArgv,
1110
shouldKeepNativeHookRelayInProcess,
@@ -16,9 +15,6 @@ import {
1615
type RespawnChildRuntime,
1716
} from "./process/respawn-child-runner.js";
1817

19-
// Node 24.0-24.14 can deadlock during ESM module loading when compile cache is
20-
// enabled on Windows npm-global installs. Keep the skip scoped to that platform.
21-
const MIN_COMPILE_CACHE_NODE_24_MINOR = 15;
2218
const COMPILE_CACHE_DISABLED_RESPAWNED_ENV = "OPENCLAW_COMPILE_CACHE_DISABLED_RESPAWNED";
2319

2420
export function resolveEntryInstallRoot(entryFile: string): string {
@@ -42,38 +38,13 @@ function isNodeCompileCacheRequested(env: NodeJS.ProcessEnv | undefined): boolea
4238
return env?.NODE_COMPILE_CACHE !== undefined && !isNodeCompileCacheDisabled(env);
4339
}
4440

45-
function isNodeVersionAffectedByCompileCacheDeadlock(nodeVersion: string | undefined): boolean {
46-
if (!nodeVersion) {
47-
return false;
48-
}
49-
const match = nodeVersion.match(/^(\d+)\.(\d+)/);
50-
if (!match) {
51-
return false;
52-
}
53-
const major = Number.parseInt(expectDefined(match[1], "compile-cache major version capture"), 10);
54-
const minor = Number.parseInt(expectDefined(match[2], "compile-cache minor version capture"), 10);
55-
if (major !== 24) {
56-
return false;
57-
}
58-
return minor < MIN_COMPILE_CACHE_NODE_24_MINOR;
59-
}
60-
6141
function shouldEnableOpenClawCompileCache(params: {
6242
env?: NodeJS.ProcessEnv;
6343
installRoot: string;
64-
nodeVersion?: string;
65-
platform?: NodeJS.Platform;
6644
}): boolean {
67-
if (isNodeCompileCacheDisabled(params.env)) {
68-
return false;
69-
}
70-
if (
71-
(params.platform ?? process.platform) === "win32" &&
72-
isNodeVersionAffectedByCompileCacheDeadlock(params.nodeVersion ?? process.versions.node)
73-
) {
74-
return false;
75-
}
76-
return !isSourceCheckoutInstallRoot(params.installRoot);
45+
return (
46+
!isNodeCompileCacheDisabled(params.env) && !isSourceCheckoutInstallRoot(params.installRoot)
47+
);
7748
}
7849

7950
function sanitizeCompileCachePathSegment(value: string): string {
@@ -144,7 +115,6 @@ function buildOpenClawCompileCacheRespawnPlan(params: {
144115
installRoot: string;
145116
argv?: string[];
146117
compileCacheDir?: string;
147-
nodeVersion?: string;
148118
platform?: NodeJS.Platform;
149119
}): OpenClawCompileCacheRespawnPlan | undefined {
150120
const env = params.env ?? process.env;
@@ -153,11 +123,7 @@ function buildOpenClawCompileCacheRespawnPlan(params: {
153123
if (shouldKeepNativeHookRelayInProcess(argv, platform)) {
154124
return undefined;
155125
}
156-
const needsDisabledCompileCacheRespawn =
157-
isSourceCheckoutInstallRoot(params.installRoot) ||
158-
(platform === "win32" &&
159-
isNodeVersionAffectedByCompileCacheDeadlock(params.nodeVersion ?? process.versions.node));
160-
if (!needsDisabledCompileCacheRespawn) {
126+
if (!isSourceCheckoutInstallRoot(params.installRoot)) {
161127
return undefined;
162128
}
163129
if (env[COMPILE_CACHE_DISABLED_RESPAWNED_ENV] === "1") {

0 commit comments

Comments
 (0)