mirror of
https://github.com/openclaw/openclaw.git
synced 2026-09-30 17:49:14 +08:00
fix: probe SQLite when Node denies worker threads (#152075)
This commit is contained in:
+8
-3
@@ -56,12 +56,17 @@ function isSqliteCapabilities(value) {
|
||||
);
|
||||
}
|
||||
|
||||
async function probeCurrentSqliteInWorker() {
|
||||
async function probeCurrentSqlite() {
|
||||
let worker;
|
||||
try {
|
||||
if (typeof process.getBuiltinModule?.("node:sqlite")?.DatabaseSync !== "function") {
|
||||
const DatabaseSync = process.getBuiltinModule?.("node:sqlite")?.DatabaseSync;
|
||||
if (typeof DatabaseSync !== "function") {
|
||||
return unavailableSqliteCapabilities(new Error("node:sqlite is unavailable"));
|
||||
}
|
||||
// Keep the real capability check when Node's permission policy forbids workers.
|
||||
if (!process.versions.bun && process.permission?.has("worker") === false) {
|
||||
return probeSqlite(DatabaseSync);
|
||||
}
|
||||
const env = Object.fromEntries(
|
||||
Object.entries(process.env).filter(([name]) => !/^(NODE_OPTIONS|BUN_OPTIONS)$/i.test(name)),
|
||||
);
|
||||
@@ -126,7 +131,7 @@ async function probeCurrentSqliteInWorker() {
|
||||
|
||||
export function detectCurrentSqliteCapabilities() {
|
||||
// Publish the Promise before Worker construction can notify another startup caller.
|
||||
globalThis[capabilityCacheKey] ??= Promise.resolve().then(probeCurrentSqliteInWorker);
|
||||
globalThis[capabilityCacheKey] ??= Promise.resolve().then(probeCurrentSqlite);
|
||||
return Promise.resolve(globalThis[capabilityCacheKey]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user