Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db.serialize() still crashing with Electron #1223

Open
TheOneTheOnlyJJ opened this issue Jul 14, 2024 · 5 comments
Open

db.serialize() still crashing with Electron #1223

TheOneTheOnlyJJ opened this issue Jul 14, 2024 · 5 comments

Comments

@TheOneTheOnlyJJ
Copy link

TheOneTheOnlyJJ commented Jul 14, 2024

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
Copy link
Author

TheOneTheOnlyJJ commented Jul 23, 2024

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

@mceachen
Copy link
Member

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.

@TheOneTheOnlyJJ
Copy link
Author

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.

@josephbinoy
Copy link

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

@mceachen
Copy link
Member

mceachen commented Sep 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants