Skip to content

Commit e2407bb

Browse files
Update branch
1 parent 8266080 commit e2407bb

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

packages/node/download_core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const downloadAsset = async (asset, destination) => {
4848

4949
// Check if file exists and has correct hash
5050
const currentHash = await hashLocal(destinationPath);
51-
if (currentHash === expectedHash) {
51+
if (currentHash == expectedHash) {
5252
console.debug(`${destination} is up-to-date, skipping download`);
5353
return;
5454
}
@@ -83,7 +83,7 @@ const checkAsset = async (asset, destination) => {
8383
expectedHash,
8484
currentHash,
8585
exists: currentHash !== null,
86-
isValid: currentHash === expectedHash
86+
isValid: currentHash == expectedHash
8787
};
8888
};
8989

packages/node/src/db/NodeSqliteWorker.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { threadId } from 'node:worker_threads';
21
import type { DatabaseSync } from 'node:sqlite';
2+
import { threadId } from 'node:worker_threads';
33

4+
import { dynamicImport } from '../utils/modules.js';
45
import { AsyncDatabase, AsyncDatabaseOpenOptions } from './AsyncDatabase.js';
56
import { PowerSyncWorkerOptions } from './SqliteWorker.js';
6-
import { dynamicImport } from '../utils/modules.js';
77

88
class BlockingNodeDatabase implements AsyncDatabase {
99
private readonly db: DatabaseSync;
@@ -57,7 +57,7 @@ export async function openDatabase(worker: PowerSyncWorkerOptions, options: Asyn
5757
const { DatabaseSync } = await dynamicImport('node:sqlite');
5858

5959
const baseDB = new DatabaseSync(options.path, { allowExtension: true });
60-
baseDB.loadExtension(worker.extensionPath());
60+
baseDB.loadExtension(worker.extensionPath(), 'sqlite3_powersync_init');
6161

6262
return new BlockingNodeDatabase(baseDB, options.isWriter);
6363
}

packages/node/src/db/SqliteWorker.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,28 @@ export function startPowerSyncWorker(options?: Partial<PowerSyncWorkerOptions>)
3535
if (arch == 'x64') {
3636
extensionPath = 'powersync.dll';
3737
} else {
38-
throw 'Windows platform only supports x64 architecture.';
38+
throw new Error('Windows platform only supports x64 architecture.');
3939
}
4040
} else if (platform == 'linux') {
4141
if (arch == 'x64') {
4242
extensionPath = 'libpowersync.so';
4343
} else if (arch == 'arm64') {
4444
extensionPath = 'libpowersync-aarch64.so';
4545
} else {
46-
throw 'Linux platform only supports x64 and arm64 architectures.';
46+
throw new Error('Linux platform only supports x64 and arm64 architectures.');
4747
}
4848
} else if (platform == 'darwin') {
4949
if (arch == 'x64') {
5050
extensionPath = 'libpowersync.dylib';
5151
} else if (arch == 'arm64') {
5252
extensionPath = 'libpowersync-aarch64.dylib';
5353
} else {
54-
throw 'macOS platform only supports x64 and arm64 architectures.';
54+
throw new Error('macOS platform only supports x64 and arm64 architectures.');
5555
}
5656
} else {
57-
throw 'Unknown platform, PowerSync for Node.js currently supports Windows, Linux and macOS.';
57+
throw new Error(
58+
`Unknown platform: ${platform}, PowerSync for Node.js currently supports Windows, Linux and macOS.`
59+
);
5860
}
5961

6062
let resolved: string;

packages/node/tests/utils.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import os from 'node:os';
21
import fs from 'node:fs/promises';
2+
import os from 'node:os';
33
import path from 'node:path';
44
import { ReadableStream, TransformStream } from 'node:stream/web';
55

6+
import { createLogger } from '@powersync/common';
7+
import Logger from 'js-logger';
68
import { onTestFinished, test } from 'vitest';
79
import {
810
AbstractPowerSyncDatabase,
@@ -18,8 +20,6 @@ import {
1820
SyncStatus,
1921
Table
2022
} from '../lib';
21-
import { createLogger } from '@powersync/common';
22-
import Logger from 'js-logger';
2323

2424
export async function createTempDir() {
2525
const ostmpdir = os.tmpdir();
@@ -70,7 +70,10 @@ export async function createDatabase(
7070
dbLocation: tmpdir,
7171
// Using a single read worker (instead of multiple, the default) seems to improve the reliability of tests in GH
7272
// actions. So far, we've not been able to reproduce these failures locally.
73-
readWorkerCount: 1
73+
readWorkerCount: 1,
74+
implementation: {
75+
type: 'node:sqlite'
76+
}
7477
},
7578
logger: defaultLogger,
7679
...options

0 commit comments

Comments
 (0)