From ffec7731a4ac701eb2a13c5a37edfd77ee89fd7a Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 27 Jul 2026 14:06:27 +0800 Subject: [PATCH] fix: report unavailable system Node versions accurately (#114325) --- src/daemon/runtime-paths.test.ts | 41 +++++++++++++++++++++++++++++--- src/daemon/runtime-paths.ts | 7 ++++-- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/src/daemon/runtime-paths.test.ts b/src/daemon/runtime-paths.test.ts index cbb868d0cacb..d0d6283c1ecb 100644 --- a/src/daemon/runtime-paths.test.ts +++ b/src/daemon/runtime-paths.test.ts @@ -491,7 +491,26 @@ describe("resolveSystemNodeInfo", () => { expect(execFile).not.toHaveBeenCalled(); }); - it("renders a warning when system node is too old", () => { + it("reports an unavailable system Node version while preserving the selected runtime", () => { + const selectedNode = "/Users/me/.fnm/node-22/bin/node"; + const warning = renderSystemNodeWarning( + { + path: darwinNode, + sqliteVersion: null, + version: null, + nodeSharedSqlite: false, + supported: false, + }, + selectedNode, + ); + + expect(warning).toBe( + `System Node at ${darwinNode} is available, but its version could not be determined. Using ${selectedNode} for the daemon. Install Node 24.15+ (recommended) or Node 22.22.3+ from nodejs.org or Homebrew.`, + ); + }); + + it("reports a known unsupported system Node version", () => { + const selectedNode = "/Users/me/.fnm/node-22/bin/node"; const warning = renderSystemNodeWarning( { path: darwinNode, @@ -500,11 +519,27 @@ describe("resolveSystemNodeInfo", () => { nodeSharedSqlite: false, supported: false, }, + selectedNode, + ); + + expect(warning).toBe( + `System Node 18.19.0 at ${darwinNode} is outside the supported range. Using ${selectedNode} for the daemon. Install Node 24.15+ (recommended) or Node 22.22.3+ from nodejs.org or Homebrew.`, + ); + }); + + it("does not warn for a supported system Node version", () => { + const warning = renderSystemNodeWarning( + { + path: darwinNode, + sqliteVersion: "3.51.3", + version: "24.15.0", + nodeSharedSqlite: false, + supported: true, + }, "/Users/me/.fnm/node-22/bin/node", ); - expect(warning).toContain("outside the supported range"); - expect(warning).toContain(darwinNode); + expect(warning).toBeNull(); }); it("renders a WAL safety warning for supported Node with unsafe SQLite", () => { diff --git a/src/daemon/runtime-paths.ts b/src/daemon/runtime-paths.ts index f30bcdab684d..41c05a4faccd 100644 --- a/src/daemon/runtime-paths.ts +++ b/src/daemon/runtime-paths.ts @@ -232,7 +232,7 @@ export async function resolveSystemNodeInfo(params: { return firstAvailable; } -/** Renders a warning when the system Node exists but is outside the supported range. */ +/** Renders a warning when the system Node exists but is unsuitable for the daemon. */ export function renderSystemNodeWarning( systemNode: SystemNodeInfo | null, selectedNodePath?: string, @@ -240,8 +240,11 @@ export function renderSystemNodeWarning( if (!systemNode || systemNode.supported) { return null; } - const versionLabel = systemNode.version ?? "unknown"; const selectedLabel = selectedNodePath ? ` Using ${selectedNodePath} for the daemon.` : ""; + if (systemNode.version === null) { + return `System Node at ${systemNode.path} is available, but its version could not be determined.${selectedLabel} Install Node 24.15+ (recommended) or Node 22.22.3+ from nodejs.org or Homebrew.`; + } + const versionLabel = systemNode.version; if (isSupportedNodeVersion(systemNode.version)) { const sqliteLabel = systemNode.sqliteVersion ?? "unknown"; if (systemNode.nodeSharedSqlite) {