@ultimat3/db 27.10.1 → 27.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/pglite.ts +9 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/db",
3
- "version": "27.10.1",
3
+ "version": "27.10.2",
4
4
  "description": "Postgres access, transactions, migrations and drift detection",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "test": "bun test"
34
34
  },
35
35
  "dependencies": {
36
- "@ultimat3/core": "27.10.1"
36
+ "@ultimat3/core": "27.10.2"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@electric-sql/pglite": ">=0.5.0"
package/src/pglite.ts CHANGED
@@ -212,9 +212,17 @@ export async function loadPgliteDriver(options: PgliteOptions = {}): Promise<Pgl
212
212
  } catch (error) {
213
213
  throw missing(`PGlite could not open its data directory (dataDir=${dataDir})`, error);
214
214
  }
215
+ // Ready before it is handed back, asked the way `restore` asks. PGlite 0.5.10 runs `dumpDataDir`
216
+ // and `close` inside its query mutex, and either, asked mid-`initdb`, waits for a readiness that
217
+ // never comes: `x db gen` spun at full CPU until CI's timeout (`pglite-ready.test.ts`). A boot
218
+ // that fails here is not reported here: the caller's first statement types it, as it always has.
219
+ const ready = await driver.query('select 1').then(
220
+ () => true,
221
+ () => false,
222
+ );
215
223
  // Taken before the caller's first statement, so what is cached is `initdb`'s output and nothing
216
224
  // of the caller's. A dump that fails leaves no cache and a working database.
217
- if (file !== undefined && key !== undefined && driver.dumpDataDir !== undefined) {
225
+ if (ready && file !== undefined && key !== undefined && driver.dumpDataDir !== undefined) {
218
226
  try {
219
227
  // Uncompressed, by measurement: gzip costs the boot that WRITES the snapshot ~0.3 s of
220
228
  // CPU and saves nothing on the one that reads it. A fresh CI checkout always writes, so