Skip to content

Commit e365c6f

Browse files
committed
Reduce read workers to improve test reliability
1 parent a2067d1 commit e365c6f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/node/tests/PowerSyncDatabase.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ databaseTest('links powersync', async ({ database }) => {
4343
await database.get('select powersync_rs_version();');
4444
});
4545

46-
databaseTest('runs queries on multiple threads', async ({ database }) => {
46+
tempDirectoryTest('runs queries on multiple threads', async ({ tmpdir }) => {
47+
const database = new PowerSyncDatabase({
48+
schema: AppSchema,
49+
database: {
50+
dbFilename: 'test.db',
51+
dbLocation: tmpdir
52+
}
53+
});
4754
const threads = new Set<number>();
4855

4956
const collectWorkerThreadId = async () => {
@@ -58,6 +65,7 @@ databaseTest('runs queries on multiple threads', async ({ database }) => {
5865
}
5966

6067
const res = await Promise.all(queryTasks);
68+
await database.close();
6169
expect(res).toHaveLength(10);
6270
expect([...threads]).toHaveLength(5);
6371
});

packages/node/tests/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export async function createDatabase(
6767
schema: AppSchema,
6868
database: {
6969
dbFilename: 'test.db',
70-
dbLocation: tmpdir
70+
dbLocation: tmpdir,
71+
readWorkerCount: 1
7172
},
7273
logger: defaultLogger,
7374
...options

0 commit comments

Comments
 (0)