Skip to content

Commit

Permalink
Forcing require of the native SQLite module
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioszabo committed Oct 28, 2024
1 parent a8ecf17 commit 6016688
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
10 changes: 8 additions & 2 deletions src/state-store/sql.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 6016688

Please sign in to comment.