fix: report unavailable system Node versions accurately (#114325)

This commit is contained in:
Dallin Romney
2026-07-27 14:06:27 +08:00
committed by GitHub
parent 9310586b09
commit ffec7731a4
2 changed files with 43 additions and 5 deletions
+38 -3
View File
@@ -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", () => {
+5 -2
View File
@@ -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) {