fix(db): share registry across bundled copies
Quality / quality (ubuntu-latest) (push) Failing after 9m51s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
2026-08-13 19:10:51 +05:30
parent 5106256401
commit f0447fddb0
3 changed files with 32 additions and 7 deletions
+13
View File
@@ -92,3 +92,16 @@ test("registry closes every database and clears itself when one close fails", as
expect(secondClosed).toBe(true);
expect(databaseNames()).toEqual([]);
});
test("separately evaluated package copies share the process-wide registry", async () => {
await closeDatabases();
const secondCopy = await import(`../src/client.ts?copy=${crypto.randomUUID()}`);
const main = createDb(sqlite(":memory:"));
setDb(main);
expect(secondCopy.hasDb()).toBe(true);
expect(secondCopy.getDb()).toBe(main);
await secondCopy.closeDatabases();
expect(hasDb()).toBe(false);
});