From b3bc186129e8a292f40274344e4179cee5afd93c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Szabo?= Date: Mon, 28 Oct 2024 10:21:14 -0300 Subject: [PATCH 1/3] Unpacking better-sqlite3 --- script/electron-builder.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script/electron-builder.js b/script/electron-builder.js index 8032f8ce3f..ffaf4831e0 100644 --- a/script/electron-builder.js +++ b/script/electron-builder.js @@ -241,6 +241,7 @@ let options = { "afterSign": "script/mac-notarise.js", "asarUnpack": [ "node_modules/github/bin/*", + "node_modules/better-sqlite3/*", "node_modules/github/lib/*", // Resolves Error in console "**/node_modules/dugite/git/**", // Include dugite postInstall output (matching glob used for Atom) "**/node_modules/spellchecker/**", // Matching Atom Glob From a8ecf1701846ea235c787da7105b3ad9cded2aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Szabo?= Date: Mon, 28 Oct 2024 15:39:16 -0300 Subject: [PATCH 2/3] We don't really need to unpack SQLite3 --- script/electron-builder.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/electron-builder.js b/script/electron-builder.js index ffaf4831e0..a49fd52f40 100644 --- a/script/electron-builder.js +++ b/script/electron-builder.js @@ -111,9 +111,10 @@ let options = { // Other Exclusions "!**/._*", "!**/node_modules/*.d.ts", + "!**/node_modules/**/*.map", "!**/node_modules/.bin", "!**/node_modules/native-mate", - "!node_modules/fuzzy-native/node_modules", // node_modules of the fuzzy-native package are only required for building it + "!node_modules/@pulsar-edit/fuzzy-native/node_modules", // node_modules of the fuzzy-native package are only required for building it "!**/node_modules/spellchecker/vendor/hunspell/.*", "!**/git-utils/deps", "!**/oniguruma/deps", @@ -241,7 +242,6 @@ let options = { "afterSign": "script/mac-notarise.js", "asarUnpack": [ "node_modules/github/bin/*", - "node_modules/better-sqlite3/*", "node_modules/github/lib/*", // Resolves Error in console "**/node_modules/dugite/git/**", // Include dugite postInstall output (matching glob used for Atom) "**/node_modules/spellchecker/**", // Matching Atom Glob From 601668864617c0824deca7e104ea501d9a49ac85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Szabo?= Date: Mon, 28 Oct 2024 15:41:03 -0300 Subject: [PATCH 3/3] Forcing require of the native SQLite module --- CHANGELOG.md | 2 ++ src/state-store/sql.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3ebaed8c9..2ae8ba3ad6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ## [Unreleased] +- Fixed SQL State Storage not loading when starting Pulsar from a self-contained binary like appImage, tar.gz, etc. + ## 1.122.0 - Added a SQL State Storage alternative to IndexedDB (opt-in, off by default). diff --git a/src/state-store/sql.js b/src/state-store/sql.js index 85b92bd4a7..84cb2aebef 100644 --- a/src/state-store/sql.js +++ b/src/state-store/sql.js @@ -1,7 +1,13 @@ 'use strict'; -const sqlite3 = require('better-sqlite3'); const path = require('path'); +const nativeSQLite = require(path.join( + require.resolve('better-sqlite3'), + '..', '..', + 'build', 'Release', + 'better_sqlite3.node' +)); +const sqlite3 = require('better-sqlite3'); module.exports = class SQLStateStore { constructor(databaseName, version) { @@ -12,7 +18,7 @@ module.exports = class SQLStateStore { const dbPath = path.join(atom.getConfigDirPath(), 'session-store.db'); let db; try { - db = sqlite3(dbPath); + db = sqlite3(dbPath, {nativeBinding: nativeSQLite}); } catch(error) { atom.notifications.addFatalError('Error loading database', { stack: new Error('Error loading SQLite database for state storage').stack,