fix(desktop): upgrade better-sqlite3 to 13 so the Electron 43 installer builds and opens its database

better-sqlite3 12.8.0 has no prebuild for Electron 43 (ABI 148) and does not compile against
its V8 API, so the v1.18.0 installer build stopped in fix-native-abi and was never published.
13.2.0 ships Node-API prebuilds in the package; one binary runs on Node and Electron.

- fix-native-abi.mjs: nothing to swap when the packaged module is a Node-API prebuild.
- verify-native-abi.mjs: require the target prebuild, fail on a shadowing build/Release binary,
  and open a database through the packaged module.
- electron-builder: leave out the linux prebuilds we do not ship.

Verified: desktop 2,933 tests on Node 24, and WAL/transaction/FTS5 queries in an Electron
43.8.10 main process.
This commit is contained in:
Yun Chan 2026-11-20 15:30:08 +09:00
parent a117bc0d09
commit fb5f76f57f
9 changed files with 88 additions and 255 deletions

View file

@ -150,7 +150,48 @@ const REQUIRED_ELECTRON_ABI = [
const failures = []
const notes = []
const packagedTarget = inferPackagedTarget(packagedDir)
/**
* better-sqlite3 13+ 는 Node-API 프리빌드를 패키지에 싣는다 (prebuilds/<platform>-<arch>.node).
* Node-API 는 런타임 ABI 에 묶이지 않으므로 "호스트 Node 가 거부해야 통과" 규칙이 뒤집힌다:
* 대상 플랫폼 프리빌드가 있어야 하고, 호스트와 같은 플랫폼이면 실제로 열어 질의까지 해 본다.
* build/Release 바이너리가 함께 있으면 로더가 그것을 먼저 집으므로(옛 ABI 종속 빌드) 실패로 본다.
*/
function verifyNapiSqlite(moduleDir) {
const prebuild = join(moduleDir, 'prebuilds', `${packagedTarget.platform}-${packagedTarget.arch}.node`)
if (!existsSync(prebuild)) return null
if (existsSync(join(moduleDir, 'build', 'Release', 'better_sqlite3.node'))) {
return { failure: 'better-sqlite3: Node-API 프리빌드와 build/Release 바이너리가 함께 있습니다 — 로더가 옛 빌드를 먼저 집습니다.' }
}
if (packagedTarget.platform !== process.platform || packagedTarget.arch !== process.arch) {
return { note: `better-sqlite3: ${packagedTarget.platform}-${packagedTarget.arch} Node-API 프리빌드 존재 확인` }
}
const probe = spawnSync(
process.execPath,
[
'-e',
`const D=require(${JSON.stringify(moduleDir)});const d=new D(':memory:');` +
`if(d.prepare('select 1 as one').get().one!==1)process.exit(3);d.close()`,
],
{ encoding: 'utf8' },
)
if (probe.status !== 0) {
const output = `${probe.stdout ?? ''}${probe.stderr ?? ''}`.trim().split(String.fromCharCode(10)).slice(0, 3).join(' | ')
return { failure: `better-sqlite3: 패키징된 Node-API 모듈이 열리지 않습니다 → ${output}` }
}
return { note: 'better-sqlite3: 패키징된 Node-API 모듈로 DB 를 열고 질의함 (런타임 ABI 무관)' }
}
for (const module of REQUIRED_ELECTRON_ABI) {
if (module.name === 'better-sqlite3') {
const napi = verifyNapiSqlite(join(unpackedRoot, 'better-sqlite3'))
if (napi) {
if (napi.failure) failures.push(napi.failure)
else notes.push(napi.note)
continue
}
}
const binaryPath = join(unpackedRoot, module.binary)
if (!existsSync(binaryPath)) {
failures.push(`${module.name}: 패키징된 네이티브 바이너리가 없습니다 → ${binaryPath}`)
@ -183,8 +224,7 @@ for (const module of REQUIRED_ELECTRON_ABI) {
}
}
const target = inferPackagedTarget(packagedDir)
const napiResults = requiredNapiResults(unpackedRoot, target)
const napiResults = requiredNapiResults(unpackedRoot, packagedTarget)
failures.push(...napiResults.failures)
notes.push(...napiResults.notes)