





















@@ -7,6 +7,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
77import { cleanupTempDirs, makeTempDir } from "../test/helpers/temp-dir.js";
88import {
99buildOpenClawCompileCacheRespawnPlan,
10+isNodeVersionAffectedByCompileCacheDeadlock,
1011isSourceCheckoutInstallRoot,
1112resolveOpenClawCompileCacheDirectory,
1213resolveEntryInstallRoot,
@@ -58,11 +59,20 @@ describe("entry compile cache", () => {
5859it("keeps compile cache enabled for packaged installs unless disabled by env", () => {
5960const root = makeTempDir(tempDirs, "openclaw-compile-cache-package-");
606161-expect(shouldEnableOpenClawCompileCache({ env: {}, installRoot: root })).toBe(true);
62+expect(
63+shouldEnableOpenClawCompileCache({
64+env: {},
65+installRoot: root,
66+nodeVersion: "24.15.0",
67+platform: "win32",
68+}),
69+).toBe(true);
6270expect(
6371shouldEnableOpenClawCompileCache({
6472env: { NODE_DISABLE_COMPILE_CACHE: "1" },
6573installRoot: root,
74+nodeVersion: "24.15.0",
75+platform: "win32",
6676}),
6777).toBe(false);
6878});
@@ -101,23 +111,50 @@ describe("entry compile cache", () => {
101111args: ["--no-warnings", path.join(root, "dist", "entry.js"), "status", "--json"],
102112env: {
103113NODE_DISABLE_COMPILE_CACHE: "1",
104-OPENCLAW_SOURCE_COMPILE_CACHE_RESPAWNED: "1",
114+OPENCLAW_COMPILE_CACHE_DISABLED_RESPAWNED: "1",
105115},
106116});
107117});
108118109-it("does not respawn packaged installs when NODE_COMPILE_CACHE is configured", () => {
119+it("does not respawn unaffected packaged installs when NODE_COMPILE_CACHE is configured", () => {
110120const root = makeTempDir(tempDirs, "openclaw-compile-cache-package-respawn-");
111121112122expect(
113123buildOpenClawCompileCacheRespawnPlan({
114124currentFile: path.join(root, "dist", "entry.js"),
115125env: { NODE_COMPILE_CACHE: "/tmp/openclaw-cache" },
116126installRoot: root,
127+nodeVersion: "24.1.0",
128+platform: "linux",
117129}),
118130).toBeUndefined();
119131});
120132133+it("builds a no-cache respawn plan for affected Windows packaged installs", () => {
134+const root = makeTempDir(tempDirs, "openclaw-compile-cache-package-win24-");
135+const entryFile = path.join(root, "dist", "entry.js");
136+137+const plan = buildOpenClawCompileCacheRespawnPlan({
138+currentFile: entryFile,
139+env: { NODE_COMPILE_CACHE: "/tmp/openclaw-cache" },
140+execArgv: ["--no-warnings"],
141+execPath: "/usr/bin/node",
142+installRoot: root,
143+argv: ["/usr/bin/node", entryFile, "doctor", "--fix", "--non-interactive"],
144+nodeVersion: "24.1.0",
145+platform: "win32",
146+});
147+148+expect(plan).toEqual({
149+command: "/usr/bin/node",
150+args: ["--no-warnings", entryFile, "doctor", "--fix", "--non-interactive"],
151+env: {
152+NODE_DISABLE_COMPILE_CACHE: "1",
153+OPENCLAW_COMPILE_CACHE_DISABLED_RESPAWNED: "1",
154+},
155+});
156+});
157+121158it("does not respawn source checkouts twice", async () => {
122159const root = makeTempDir(tempDirs, "openclaw-compile-cache-respawn-once-");
123160await fs.mkdir(path.join(root, "src"), { recursive: true });
@@ -128,7 +165,7 @@ describe("entry compile cache", () => {
128165currentFile: path.join(root, "dist", "entry.js"),
129166env: {
130167NODE_COMPILE_CACHE: "/tmp/openclaw-cache",
131-OPENCLAW_SOURCE_COMPILE_CACHE_RESPAWNED: "1",
168+OPENCLAW_COMPILE_CACHE_DISABLED_RESPAWNED: "1",
132169},
133170installRoot: root,
134171}),
@@ -246,4 +283,97 @@ describe("entry compile cache", () => {
246283vi.useRealTimers();
247284}
248285});
286+287+it("disables compile cache for early Node 24.x versions on Windows", () => {
288+const root = makeTempDir(tempDirs, "openclaw-compile-cache-node24-");
289+expect(
290+shouldEnableOpenClawCompileCache({
291+env: {},
292+installRoot: root,
293+nodeVersion: "24.1.0",
294+platform: "win32",
295+}),
296+).toBe(false);
297+expect(
298+shouldEnableOpenClawCompileCache({
299+env: {},
300+installRoot: root,
301+nodeVersion: "24.14.0",
302+platform: "win32",
303+}),
304+).toBe(false);
305+});
306+307+it("keeps compile cache enabled for early Node 24.x on non-Windows packaged installs", () => {
308+const root = makeTempDir(tempDirs, "openclaw-compile-cache-node24-nonwin-");
309+expect(
310+shouldEnableOpenClawCompileCache({
311+env: {},
312+installRoot: root,
313+nodeVersion: "24.1.0",
314+platform: "linux",
315+}),
316+).toBe(true);
317+expect(
318+shouldEnableOpenClawCompileCache({
319+env: {},
320+installRoot: root,
321+nodeVersion: "24.14.0",
322+platform: "darwin",
323+}),
324+).toBe(true);
325+});
326+327+it("keeps compile cache enabled for Node 24.15+ and other majors on Windows", () => {
328+const root = makeTempDir(tempDirs, "openclaw-compile-cache-node2415-");
329+expect(
330+shouldEnableOpenClawCompileCache({
331+env: {},
332+installRoot: root,
333+nodeVersion: "24.15.0",
334+platform: "win32",
335+}),
336+).toBe(true);
337+expect(
338+shouldEnableOpenClawCompileCache({
339+env: {},
340+installRoot: root,
341+nodeVersion: "22.22.0",
342+platform: "win32",
343+}),
344+).toBe(true);
345+expect(
346+shouldEnableOpenClawCompileCache({
347+env: {},
348+installRoot: root,
349+nodeVersion: "25.0.0",
350+platform: "win32",
351+}),
352+).toBe(true);
353+});
354+});
355+356+describe("isNodeVersionAffectedByCompileCacheDeadlock", () => {
357+it("flags Node 24.0 through 24.14 as affected", () => {
358+expect(isNodeVersionAffectedByCompileCacheDeadlock("24.0.0")).toBe(true);
359+expect(isNodeVersionAffectedByCompileCacheDeadlock("24.1.0")).toBe(true);
360+expect(isNodeVersionAffectedByCompileCacheDeadlock("24.14.0")).toBe(true);
361+});
362+363+it("does not flag Node 24.15+", () => {
364+expect(isNodeVersionAffectedByCompileCacheDeadlock("24.15.0")).toBe(false);
365+expect(isNodeVersionAffectedByCompileCacheDeadlock("24.20.1")).toBe(false);
366+});
367+368+it("does not flag other major versions", () => {
369+expect(isNodeVersionAffectedByCompileCacheDeadlock("22.22.0")).toBe(false);
370+expect(isNodeVersionAffectedByCompileCacheDeadlock("23.11.0")).toBe(false);
371+expect(isNodeVersionAffectedByCompileCacheDeadlock("25.0.0")).toBe(false);
372+});
373+374+it("handles missing or invalid versions", () => {
375+expect(isNodeVersionAffectedByCompileCacheDeadlock(undefined)).toBe(false);
376+expect(isNodeVersionAffectedByCompileCacheDeadlock("")).toBe(false);
377+expect(isNodeVersionAffectedByCompileCacheDeadlock("not-a-version")).toBe(false);
378+});
249379});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。