Skip to content

Commit cf979be

Browse files
committed
fix(daemon): distinguish shared and embedded SQLite in system Node warning
1 parent fcd2a78 commit cf979be

2 files changed

Lines changed: 43 additions & 4 deletions

File tree

‎src/daemon/runtime-paths.test.ts‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ function mockNodePathPresent(...nodePaths: string[]) {
4545
});
4646
}
4747

48-
function nodeRuntime(nodeVersion: string, sqliteVersion: string | null = "3.51.3") {
48+
function nodeRuntime(
49+
nodeVersion: string,
50+
sqliteVersion: string | null = "3.51.3",
51+
nodeSharedSqlite = false,
52+
) {
4953
return {
50-
stdout: `${JSON.stringify({ nodeVersion, sqliteVersion })}\n`,
54+
stdout: `${JSON.stringify({ nodeVersion, sqliteVersion, nodeSharedSqlite })}\n`,
5155
stderr: "",
5256
};
5357
}
@@ -402,6 +406,7 @@ describe("resolveSystemNodeInfo", () => {
402406
path: darwinNode,
403407
sqliteVersion: "3.51.3",
404408
version: "22.22.3",
409+
nodeSharedSqlite: false,
405410
supported: true,
406411
});
407412
});
@@ -432,6 +437,7 @@ describe("resolveSystemNodeInfo", () => {
432437
path: homebrewOptNode,
433438
sqliteVersion: "3.51.3",
434439
version: "22.22.3",
440+
nodeSharedSqlite: false,
435441
supported: true,
436442
});
437443
});
@@ -456,6 +462,7 @@ describe("resolveSystemNodeInfo", () => {
456462
path: homebrewOptNode,
457463
sqliteVersion: "3.51.3",
458464
version: "24.15.0",
465+
nodeSharedSqlite: false,
459466
supported: true,
460467
});
461468
expect(execFile).toHaveBeenCalledTimes(1);
@@ -490,6 +497,7 @@ describe("resolveSystemNodeInfo", () => {
490497
path: darwinNode,
491498
sqliteVersion: null,
492499
version: "18.19.0",
500+
nodeSharedSqlite: false,
493501
supported: false,
494502
},
495503
"/Users/me/.fnm/node-22/bin/node",
@@ -504,11 +512,28 @@ describe("resolveSystemNodeInfo", () => {
504512
path: darwinNode,
505513
sqliteVersion: "3.51.2",
506514
version: "24.17.0",
515+
nodeSharedSqlite: false,
507516
supported: false,
508517
});
509518

510519
expect(warning).toContain("uses SQLite 3.51.2");
511520
expect(warning).toContain("not WAL-reset-safe");
521+
expect(warning).toContain("Install Node 24.15+");
522+
});
523+
524+
it("renders a shared-system-SQLite remediation when Node is supported but the system library is unsafe", () => {
525+
const warning = renderSystemNodeWarning({
526+
path: "/usr/bin/node",
527+
sqliteVersion: "3.51.2",
528+
version: "24.17.0",
529+
nodeSharedSqlite: true,
530+
supported: false,
531+
});
532+
533+
expect(warning).toContain("uses shared system SQLite 3.51.2");
534+
expect(warning).toContain("not WAL-reset-safe");
535+
expect(warning).toContain("Upgrade the system SQLite library");
536+
expect(warning).not.toContain("Install Node 24.15+");
512537
});
513538

514539
it("uses validated custom Program Files roots on Windows", async () => {

‎src/daemon/runtime-paths.ts‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,15 @@ try {
9292
db.close();
9393
}
9494
} catch {}
95-
process.stdout.write(JSON.stringify({ nodeVersion: process.versions.node, sqliteVersion }));
95+
const variables = (process.config && process.config.variables) || {};
96+
const nodeSharedSqlite = variables.node_shared_sqlite === true || variables.node_shared_sqlite === "true";
97+
process.stdout.write(JSON.stringify({ nodeVersion: process.versions.node, sqliteVersion, nodeSharedSqlite }));
9698
`;
9799

98100
type NodeRuntimeInfo = {
99101
nodeVersion: string | null;
100102
sqliteVersion: string | null;
103+
nodeSharedSqlite: boolean;
101104
supported: boolean;
102105
};
103106

@@ -112,26 +115,30 @@ async function resolveNodeRuntimeInfo(
112115
const parsed = JSON.parse(stdout) as {
113116
nodeVersion?: unknown;
114117
sqliteVersion?: unknown;
118+
nodeSharedSqlite?: unknown;
115119
};
116120
const nodeVersion = typeof parsed.nodeVersion === "string" ? parsed.nodeVersion : null;
117121
const sqliteVersion = typeof parsed.sqliteVersion === "string" ? parsed.sqliteVersion : null;
122+
const nodeSharedSqlite = parsed.nodeSharedSqlite === true || parsed.nodeSharedSqlite === "true";
118123
return {
119124
nodeVersion,
120125
sqliteVersion,
126+
nodeSharedSqlite,
121127
supported:
122128
isSupportedNodeVersion(nodeVersion) &&
123129
sqliteVersion !== null &&
124130
isSqliteWalResetSafeVersion(sqliteVersion),
125131
};
126132
} catch {
127-
return { nodeVersion: null, sqliteVersion: null, supported: false };
133+
return { nodeVersion: null, sqliteVersion: null, nodeSharedSqlite: false, supported: false };
128134
}
129135
}
130136

131137
type SystemNodeInfo = {
132138
path: string;
133139
sqliteVersion: string | null;
134140
version: string | null;
141+
nodeSharedSqlite: boolean;
135142
supported: boolean;
136143
};
137144

@@ -211,6 +218,7 @@ export async function resolveSystemNodeInfo(params: {
211218
path: systemNode,
212219
sqliteVersion: runtime.sqliteVersion,
213220
version: runtime.nodeVersion,
221+
nodeSharedSqlite: runtime.nodeSharedSqlite,
214222
supported: runtime.supported,
215223
};
216224
if (info.supported) {
@@ -233,6 +241,12 @@ export function renderSystemNodeWarning(
233241
const selectedLabel = selectedNodePath ? ` Using ${selectedNodePath} for the daemon.` : "";
234242
if (isSupportedNodeVersion(systemNode.version)) {
235243
const sqliteLabel = systemNode.sqliteVersion ?? "unknown";
244+
if (systemNode.nodeSharedSqlite) {
245+
return (
246+
`System Node ${versionLabel} at ${systemNode.path} uses shared system SQLite ${sqliteLabel}, which is not WAL-reset-safe.${selectedLabel} ` +
247+
"Upgrade the system SQLite library to 3.51.3+ (or patched 3.50.7+/3.44.6+), or install a Node build that embeds a safe version."
248+
);
249+
}
236250
return `System Node ${versionLabel} at ${systemNode.path} uses SQLite ${sqliteLabel}, which is not WAL-reset-safe.${selectedLabel} Install Node 24.15+ (recommended) or Node 22.22.3+ from nodejs.org or Homebrew.`;
237251
}
238252
return `System Node ${versionLabel} at ${systemNode.path} is outside the supported range.${selectedLabel} Install Node 24.15+ (recommended) or Node 22.22.3+ from nodejs.org or Homebrew.`;

0 commit comments

Comments
 (0)