mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:10:44 +00:00
fix: environment edge case launcher regression (#74696)
Co-authored-by: openclaw-clawsweeper[bot] <280122609+openclaw-clawsweeper[bot]@users.noreply.github.com>
This commit is contained in:
@@ -47,7 +47,7 @@ const isSourceCheckoutLauncher = () =>
|
||||
|
||||
const isNodeCompileCacheDisabled = () => process.env.NODE_DISABLE_COMPILE_CACHE !== undefined;
|
||||
const isNodeCompileCacheRequested = () =>
|
||||
process.env.NODE_COMPILE_CACHE !== undefined && !isNodeCompileCacheDisabled();
|
||||
Boolean(process.env.NODE_COMPILE_CACHE) && !isNodeCompileCacheDisabled();
|
||||
const sanitizeCompileCachePathSegment = (value) => {
|
||||
const normalized = value.replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
|
||||
return normalized.length > 0 ? normalized : "unknown";
|
||||
|
||||
@@ -201,6 +201,32 @@ describe("openclaw launcher", () => {
|
||||
expect(result.stdout).toContain(path.join(".node-compile-cache", "openclaw", "2026.4.29"));
|
||||
});
|
||||
|
||||
it("falls back to the default packaged launcher compile cache when NODE_COMPILE_CACHE is empty", async () => {
|
||||
const fixtureRoot = await makeLauncherFixture(fixtureRoots);
|
||||
const runCwd = makeTempDir(fixtureRoots, "openclaw-launcher-cwd-");
|
||||
await fs.writeFile(path.join(fixtureRoot, "package.json"), '{"version":"2026.4.29"}\n');
|
||||
await fs.writeFile(
|
||||
path.join(fixtureRoot, "dist", "entry.js"),
|
||||
[
|
||||
'import module from "node:module";',
|
||||
'process.stdout.write(module.getCompileCacheDir?.() ?? "cache:disabled");',
|
||||
].join("\n"),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
const result = spawnSync(process.execPath, [path.join(fixtureRoot, "openclaw.mjs")], {
|
||||
cwd: runCwd,
|
||||
env: launcherEnv({
|
||||
NODE_COMPILE_CACHE: "",
|
||||
}),
|
||||
encoding: "utf8",
|
||||
});
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stdout).toContain(path.join("node-compile-cache", "openclaw", "2026.4.29"));
|
||||
expect(result.stdout).not.toContain(path.join(runCwd, "openclaw"));
|
||||
});
|
||||
|
||||
it("enables compile cache for packaged launchers", async () => {
|
||||
const fixtureRoot = await makeLauncherFixture(fixtureRoots);
|
||||
await addCompileCacheProbe(fixtureRoot);
|
||||
|
||||
Reference in New Issue
Block a user