better-sqlite3 icon indicating copy to clipboard operation
better-sqlite3 copied to clipboard

db.serialize() still crashing with Electron

Open TheOneTheOnlyJJ opened this issue 1 year ago • 5 comments

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.

TheOneTheOnlyJJ avatar Jul 14 '24 12:07 TheOneTheOnlyJJ

Does anyone have/know a fix for this? Since I've had this issue, I've been unable to develop my project further.

TheOneTheOnlyJJ avatar Jul 23 '24 16:07 TheOneTheOnlyJJ

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.

mceachen avatar Jul 23 '24 17:07 mceachen

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.

TheOneTheOnlyJJ avatar Jul 24 '24 08:07 TheOneTheOnlyJJ

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 avatar Sep 02 '24 22:09 josephbinoy

@josephbinoy thanks for sharing that link, that was news to me!

mceachen avatar Sep 03 '24 01:09 mceachen

Closing: https://github.com/WiseLibs/better-sqlite3/issues/1223#issuecomment-2325354144

mceachen avatar Oct 22 '24 04:10 mceachen