From da61b023fe1c297f46274b0580299c3fc8947627 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jul 2026 20:05:00 +0000 Subject: [PATCH 1/3] deps: bump electron from 42.5.1 to 43.1.0 in /electron --- updated-dependencies: - dependency-name: electron dependency-version: 43.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- electron/package-lock.json | 8 ++++---- electron/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/electron/package-lock.json b/electron/package-lock.json index ed7a4927152..b5fda4c818d 100644 --- a/electron/package-lock.json +++ b/electron/package-lock.json @@ -12,7 +12,7 @@ "electron-updater": "^6.8.9" }, "devDependencies": { - "electron": "^42.5.1", + "electron": "^43.1.0", "electron-builder": "^26.15.3" }, "engines": { @@ -1367,9 +1367,9 @@ } }, "node_modules/electron": { - "version": "42.5.1", - "resolved": "https://registry.npmjs.org/electron/-/electron-42.5.1.tgz", - "integrity": "sha512-2VFNJcHHbrhIpGsJHdkLoi/nWPZPxN3GHVPe+9At3Oz3/TJRwpr+7JL97ddBDbKyLmHGx3GfI2jvzcEQL28uFw==", + "version": "43.1.0", + "resolved": "https://registry.npmjs.org/electron/-/electron-43.1.0.tgz", + "integrity": "sha512-DPfxpQLd4NL3BJ8DBxYAfmLUKKesF5Rx9dQx5FyczAP8bhOPScjHE48GArVeXu68LlAainuwkmQTQvdZwpIIAQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/electron/package.json b/electron/package.json index 90f35b9b11b..22381f4d243 100644 --- a/electron/package.json +++ b/electron/package.json @@ -28,7 +28,7 @@ "electron-updater": "^6.8.9" }, "devDependencies": { - "electron": "^42.5.1", + "electron": "^43.1.0", "electron-builder": "^26.15.3" }, "overrides": { From 0d4e02714732d01f85024e8ad5c9d77110e49ed2 Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Tue, 7 Jul 2026 21:41:51 -0300 Subject: [PATCH 2/3] fix(electron): build native deps from source for electron 43 (better-sqlite3 ABI 148) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Electron 43 bumps NODE_MODULE_VERSION to 148, but better-sqlite3@12.11.1's prebuilt binaries only go up to electron-v146 (electron 42). With the default buildFromSource=false, @electron/rebuild tries to fetch a nonexistent electron-v148 prebuild and silently leaves the Node-ABI (137) binary in the bundle, so the packaged app fails with 'Nenhum driver SQLite disponível — better-sqlite3 (falhou)' and never serves. buildDependenciesFromSource=true makes electron-builder compile better-sqlite3 from source against the electron 43 headers (ABI 148), which is robust to any electron version regardless of prebuild availability. Verified locally that electron-rebuild --version 43.1.0 compiles better-sqlite3 to bin/linux-x64-148. Includes the electron 42.5.1 -> 43.1.0 bump (supersedes #6378). --- electron/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/electron/package.json b/electron/package.json index 22381f4d243..115c459e4d3 100644 --- a/electron/package.json +++ b/electron/package.json @@ -42,6 +42,7 @@ "appId": "online.omniroute.desktop", "productName": "OmniRoute", "copyright": "Copyright © 2025 OmniRoute", + "buildDependenciesFromSource": true, "directories": { "output": "dist-electron", "buildResources": "assets" From 483b15eb4b5fd03dc1de9ccfd7ab99cbcdb4f31f Mon Sep 17 00:00:00 2001 From: Diego Rodrigues de Sa e Souza Date: Tue, 7 Jul 2026 22:15:11 -0300 Subject: [PATCH 3/3] fix(electron): rebuild better-sqlite3 from source against the Electron ABI in prepare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The prior fix (buildDependenciesFromSource) was necessary but not sufficient: electron-builder's @electron/rebuild searches electron/node_modules (where better-sqlite3 does not live — it's copied into the standalone bundle), so it never rebuilt it. The bundle pipeline stripped better-sqlite3 expecting a rebuild that only happened via a prebuild download — which exists for electron 42 (v146) but NOT electron 43 (v148, absent from better-sqlite3@12.11.1), so the packaged app died with 'Nenhum driver SQLite disponível — better-sqlite3 (falhou)'. Now prepare-electron-standalone copies the full better-sqlite3 module into the standalone and compiles it from source against the Electron headers (npm_config_runtime=electron + target + disturl), landing a correct build/Release/better_sqlite3.node (NODE_MODULE_VERSION 148 for electron 43) where the 'bindings' loader resolves it — robust to any electron version, no prebuild needed. Verified locally: produces node_register_module_v148. keytar is still stripped for electron-builder's @electron/rebuild (it ships electron prebuilds). --- scripts/build/prepare-electron-standalone.mjs | 90 +++++++++++++++++-- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/scripts/build/prepare-electron-standalone.mjs b/scripts/build/prepare-electron-standalone.mjs index 96e504df2d0..951e73799d9 100644 --- a/scripts/build/prepare-electron-standalone.mjs +++ b/scripts/build/prepare-electron-standalone.mjs @@ -1,8 +1,9 @@ #!/usr/bin/env node -import { existsSync, lstatSync, readdirSync, rmSync } from "node:fs"; +import { cpSync, existsSync, lstatSync, readFileSync, readdirSync, rmSync } from "node:fs"; import { basename, dirname, join, relative } from "node:path"; import { fileURLToPath } from "node:url"; +import { spawnSync } from "node:child_process"; import { assembleStandalone } from "./assembleStandalone.mjs"; const __filename = fileURLToPath(import.meta.url); @@ -70,17 +71,86 @@ function removeGeneratedElectronArtifacts() { // --- Electron-UNIQUE: remove native modules for electron-builder ABI rebuild --- -function removeNativeModules(baseDir) { +function removeNativeModules(baseDir, prefixes = ["keytar"]) { if (!existsSync(baseDir)) return; const dirs = readdirSync(baseDir); for (const dir of dirs) { - if (dir.startsWith("better-sqlite3") || dir.startsWith("keytar")) { + if (prefixes.some((p) => dir.startsWith(p))) { const fullPath = join(baseDir, dir); rmSync(fullPath, { recursive: true, force: true }); } } } +// --- Electron-UNIQUE: rebuild better-sqlite3 against the Electron ABI -------- +// +// The `npm ci` at the repo root compiles better-sqlite3 for the CI *Node* ABI +// (e.g. 137 for Node 24). The packaged app runs its Next.js server via +// ELECTRON_RUN_AS_NODE, so it needs the *Electron* ABI (146 for electron 42, +// 148 for electron 43). We cannot rely on electron-builder's @electron/rebuild +// here: it searches `electron/node_modules` (where better-sqlite3 does not live) +// and, with the default prebuild path, tries to fetch a prebuilt binary — but +// better-sqlite3@12.11.1 only ships prebuilds up to electron-v146, so electron +// 43 (v148) silently gets no rebuild and the app dies with "Nenhum driver +// SQLite disponível — better-sqlite3 (falhou)". +// +// Instead we copy the *full* module (source + binding.gyp) from the root into +// the standalone and compile it from source against the Electron headers, so +// `bindings` finds a correct build/Release/better_sqlite3.node regardless of +// prebuild availability. Robust to any current/future electron version. + +function readElectronVersion() { + const pkg = JSON.parse(readFileSync(join(ROOT, "electron", "package.json"), "utf8")); + const raw = pkg.devDependencies?.electron || pkg.dependencies?.electron || ""; + return String(raw).replace(/^[\^~]/, ""); +} + +function rebuildBetterSqlite3ForElectron(standaloneNodeModules) { + const srcMod = join(ROOT, "node_modules", "better-sqlite3"); + if (!existsSync(srcMod)) { + console.warn("[electron] better-sqlite3 not found at repo root — skipping ABI rebuild."); + return; + } + const electronVersion = readElectronVersion(); + if (!electronVersion) { + throw new Error("[electron] could not resolve electron version for better-sqlite3 rebuild."); + } + const destMod = join(standaloneNodeModules, "better-sqlite3"); + // copyNatives only copies build/; we need the full module (src + binding.gyp) + // to compile from source. Overwrite the copied Node-ABI build in the process. + cpSync(srcMod, destMod, { recursive: true, force: true }); + rmSync(join(destMod, "build"), { recursive: true, force: true }); + + console.log(`[electron] rebuilding better-sqlite3 against electron ${electronVersion} ABI…`); + const result = spawnSync( + process.platform === "win32" ? "npx.cmd" : "npx", + ["--yes", "node-gyp", "rebuild"], + { + cwd: destMod, + stdio: "inherit", + // Compile against the Electron headers (not Node's) so the .node lands in + // build/Release with the Electron NODE_MODULE_VERSION. No shell interpolation. + env: { + ...process.env, + npm_config_runtime: "electron", + npm_config_target: electronVersion, + npm_config_disturl: "https://electronjs.org/headers", + npm_config_arch: process.arch, + npm_config_build_from_source: "true", + }, + } + ); + if (result.status !== 0) { + throw new Error( + `[electron] better-sqlite3 rebuild against electron ${electronVersion} failed (exit ${result.status}).` + ); + } + // Drop the now-unneeded compile inputs to keep the packaged app lean. + for (const dir of ["deps", "src", "build/Debug", "build/obj.target"]) { + rmSync(join(destMod, dir), { recursive: true, force: true }); + } +} + function logContextualError(error) { const message = error instanceof Error ? error.message : String(error); console.error(`[electron] failed to prepare standalone bundle: ${message}`); @@ -108,9 +178,17 @@ assembleStandalone({ // Electron-UNIQUE post-assembly steps removeGeneratedElectronArtifacts(); -// Strip better-sqlite3 and keytar so electron-builder rebuilds them against Electron ABI -removeNativeModules(join(ELECTRON_STANDALONE_DIR, "node_modules")); -removeNativeModules(join(ELECTRON_STANDALONE_DIR, ".next", "node_modules")); +// Rebuild better-sqlite3 from source against the Electron ABI in the primary +// node_modules (where the standalone server resolves it). keytar is still +// stripped so electron-builder's @electron/rebuild handles it (it has electron +// prebuilds); also drop any stray Node-ABI better-sqlite3 under .next/node_modules +// so it cannot shadow the rebuilt one. +rebuildBetterSqlite3ForElectron(join(ELECTRON_STANDALONE_DIR, "node_modules")); +removeNativeModules(join(ELECTRON_STANDALONE_DIR, "node_modules"), ["keytar"]); +removeNativeModules(join(ELECTRON_STANDALONE_DIR, ".next", "node_modules"), [ + "better-sqlite3", + "keytar", +]); console.log( `[electron] prepared standalone bundle: ${relative(ROOT, ELECTRON_STANDALONE_DIR) || "."}`