db.serialize() still crashing with Electron
I've read #981, and sadly I come here to report that the issue is still not fixed.
Running the following code in Electron's main process:
import Database from "better-sqlite3";
import { join } from "path";
export const initDatabase = (dbDir: string): void => {
console.log(`Initialising database at : ${dbDir}.`);
const dbPath = join(dbDir, "BlackBoxDB.sqlite");
const db = new Database(dbPath);
const dbBuffer = db.serialize();
console.log(dbBuffer.toString());
db.close();
};
(Either before or after the Electron boilerplate app initialisation steps) Yields the following V8 error:
[7680:0714/153927.837:ERROR:node_bindings.cc(158)] Fatal error in V8: v8_ArrayBuffer_NewBackingStore When the V8 Sandbox is enabled, ArrayBuffer backing stores must be allocated inside the sandbox address space. Please use an appropriate ArrayBuffer::Allocator to allocate these buffers, or disable the sandbox.
[7680:0714/153927.838:ERROR:crashpad_client_win.cc(868)] not connected
Software used:
- node.js v20.15.1 & v22.4.1 (tried both, same result)
- electron.js v31.0.2
- better-sqlite3 v11.1.2
This is a blocker issue for me, as I have no alternative. There is nothing else in the project yet, as setting up the database is the core of what I'm trying to build. I need to get this fixed one way or another.
Does anyone have/know a fix for this? Since I've had this issue, I've been unable to develop my project further.
Does anyone have/know a fix for this?
There are at least two non-blocking alternatives to backing up SQLite, but I’d try https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#backupdestination-options---promise first.
There are at least two non-blocking alternatives to backing up SQLite, but I’d try https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#backupdestination-options---promise first.
Thank you! I was asking more about the underlying issue itself, as there was some talk about a fix in #1036 shortly after I opened this, but nothing new was discussed since then.
idk if this is related but db.serialize() doesn't work if your db is in WAL mode.
source: https://sqlite.org/forum/forumpost/a7e272cee9ac469f
@josephbinoy thanks for sharing that link, that was news to me!
Closing: https://github.com/WiseLibs/better-sqlite3/issues/1223#issuecomment-2325354144