Skip to content

Commit 4b55ed4

Browse files
add another test
1 parent d90b869 commit 4b55ed4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/tests/sqlite/rawQueries.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,5 +729,35 @@ export function registerBaseTests() {
729729
expect(results.map((r) => r.rows?.length)).deep.equal(Array(promises.length).fill(50000));
730730
}
731731
});
732+
733+
it('Should close correctly with transaction hooks', async () => {
734+
const dbName = 'test-transaction-close';
735+
736+
// populate test data
737+
const db = open(dbName);
738+
await db.execute('CREATE TABLE IF NOT EXISTS t1(id INTEGER PRIMARY KEY, c TEXT)');
739+
await db.execute('DELETE FROM t1');
740+
db.close();
741+
742+
for (let i = 1; i < 10; i++) {
743+
const db = open(dbName, {
744+
numReadConnections: NUM_READ_CONNECTIONS
745+
});
746+
747+
await db.execute('DELETE FROM t1');
748+
749+
// ensure a regular query
750+
await db.writeTransaction(async (tx) => {
751+
await tx.execute('INSERT INTO t1(id, c) VALUES(?, ?)', [1, `value${i + 1}`]);
752+
// Don't await these
753+
for (let i = 0; i < 100; i++) {
754+
tx.execute('INSERT INTO t1(id, c) VALUES(?, ?)', [i + 2, `value${i + 1}`]);
755+
}
756+
});
757+
758+
// This should not crash
759+
db.close();
760+
}
761+
});
732762
});
733763
}

0 commit comments

Comments
 (0)