Skip to content

Commit fb3ede4

Browse files
committed
More migrations
1 parent fa15ca4 commit fb3ede4

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

packages/attachments/rollup.config.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@ import { dts } from 'rollup-plugin-dts';
55

66
/** @type {import('rollup').RollupOptions} */
77
export default (commandLineArgs) => {
8-
const sourceMap = (commandLineArgs.sourceMap || 'true') == 'true';
9-
10-
// Clears rollup CLI warning https://github.com/rollup/rollup/issues/2694
11-
delete commandLineArgs.sourceMap;
12-
138
return [
149
{
1510
input: 'src/index.ts',
1611
output: {
1712
format: 'cjs',
1813
file: 'dist/index.cjs',
19-
sourcemap: sourceMap,
14+
sourcemap: true,
2015
exports: 'named'
2116
},
2217
plugins: [
@@ -25,7 +20,7 @@ export default (commandLineArgs) => {
2520
typescript({
2621
tsconfig: './tsconfig.json',
2722
outDir: 'dist',
28-
sourceMap
23+
sourceMap: true
2924
})
3025
],
3126
external: ['@powersync/common']

packages/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@
6666
},
6767
"dependencies": {
6868
"@powersync/common": "workspace:*",
69+
"async-mutex": "^0.5.0",
6970
"comlink": "^4.4.2",
7071
"undici": "^7.11.0",
7172
"bson": "^6.10.4"
7273
},
7374
"devDependencies": {
7475
"@powersync/drizzle-driver": "workspace:*",
75-
"@types/async-lock": "^1.4.0",
7676
"@types/node": "^24.2.0",
7777
"better-sqlite3": "^12.2.0",
7878
"drizzle-orm": "^0.35.2",

packages/node/src/sync/stream/NodeStreamingSyncImplementation.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import {
44
LockOptions,
55
LockType
66
} from '@powersync/common';
7-
import Lock from 'async-lock';
7+
import { Mutex } from 'async-mutex';
88

99
/**
1010
* Global locks which prevent multiple instances from syncing
1111
* concurrently.
1212
*/
13-
const LOCKS = new Map<string, Lock>();
13+
const LOCKS = new Map<string, Map<LockType, Mutex>>();
1414

1515
const lockTypes = new Set(Object.values(LockType));
1616

1717
export class NodeStreamingSyncImplementation extends AbstractStreamingSyncImplementation {
18-
locks: Lock;
18+
locks: Map<LockType, Mutex>;
1919

2020
constructor(options: AbstractStreamingSyncImplementationOptions) {
2121
super(options);
@@ -32,18 +32,21 @@ export class NodeStreamingSyncImplementation extends AbstractStreamingSyncImplem
3232
return;
3333
}
3434

35-
this.locks = new Lock();
35+
this.locks = new Map<LockType, Mutex>();
36+
this.locks.set(LockType.CRUD, new Mutex());
37+
this.locks.set(LockType.SYNC, new Mutex());
3638

3739
if (identifier) {
3840
LOCKS.set(identifier, this.locks);
3941
}
4042
}
4143

4244
obtainLock<T>(lockOptions: LockOptions<T>): Promise<T> {
43-
if (!lockTypes.has(lockOptions.type)) {
45+
const lock = this.locks.get(lockOptions.type);
46+
if (!lock) {
4447
throw new Error(`Lock type ${lockOptions.type} not found`);
4548
}
46-
return this.locks.acquire(lockOptions.type, async () => {
49+
return lock.runExclusive(async () => {
4750
if (lockOptions.signal?.aborted) {
4851
throw new Error('Aborted');
4952
}

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)