@aria-framework/db-worker 0.27.1 → 0.27.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 (3) hide show
  1. package/README.md +6 -0
  2. package/database.js +17 -12
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -437,6 +437,12 @@ Against 0.25.0's code, 6 of its 10 checks fail.
437
437
 
438
438
  ## Changelog
439
439
 
440
+ - **0.27.2** — a FAILED MIGRATION REJECTS `runMigrations` again on the Postgres migration-connection path.
441
+ Its `finally` did `return` after logging "Skipping the BYPASSRLS proof", and a `return` in a finally discards the
442
+ exception in flight: `runMigrations` resolved, the app booted on a half-migrated schema, and the next migrations
443
+ never ran (seen: a renumbered migration failing on every boot; the symptom was a 500 three migrations later). Now
444
+ the migration's own error propagates and the migration connection is still closed. `test/migrationFailureSurfaces.js`
445
+ (fake drivers, no server) fails against 0.27.1.
440
446
  - **0.27.1** — the UTC pin is WAITED FOR. 0.27.0 fired `SET TIME ZONE 'UTC'` from the pool's
441
447
  `connect` event without awaiting it, so the first query on every new connection was issued
442
448
  while the SET was still running: pg 8 prints "Calling client.query() when the client is already
package/database.js CHANGED
@@ -456,21 +456,26 @@ function runMigrations(migrationsDir, opts = {}) {
456
456
  // SQL that broke, at the one moment a half-applied chain makes the real cause matter most.
457
457
  // So the proof is skipped when we are already unwinding an error, and any failure of the
458
458
  // proof ITSELF is reported rather than thrown when there is a prior error to preserve.
459
+ //
460
+ // NO `return` HERE (0.27.2). This block is a `finally`, and a `return` in a finally DISCARDS the exception
461
+ // in flight: runMigrations resolved as if it had succeeded, the boot carried on with a half-migrated schema,
462
+ // and the only trace was the warning below. Found when a renumbered migration failed on every boot of a test
463
+ // database and the symptom surfaced three migrations later as a 500 on an unrelated insert.
459
464
  if (migrationError) {
460
465
  _logger.warn('Skipping the BYPASSRLS proof: a migration already failed, and its error is '
461
466
  + 'the one worth keeping. Re-run once that is fixed.');
462
- return;
463
- }
464
- const [who] = await d.all(
465
- 'SELECT current_user AS role, '
466
- + '(SELECT rolbypassrls FROM pg_roles WHERE rolname = current_user) AS bypassrls');
467
- if (who && who.bypassrls) {
468
- throw new Error(
469
- `runMigrations: after closing the migration connection the APPLICATION driver is still `
470
- + `connected as ${who.role}, which holds BYPASSRLS. Row-level security does not apply `
471
- + 'to it, so every partner boundary in this schema is inert. The application must '
472
- + 'connect as a role that owns nothing and has no BYPASSRLS (frozen spec §3); only the '
473
- + 'migration and backup roles may hold it.');
467
+ } else {
468
+ const [who] = await d.all(
469
+ 'SELECT current_user AS role, '
470
+ + '(SELECT rolbypassrls FROM pg_roles WHERE rolname = current_user) AS bypassrls');
471
+ if (who && who.bypassrls) {
472
+ throw new Error(
473
+ `runMigrations: after closing the migration connection the APPLICATION driver is still `
474
+ + `connected as ${who.role}, which holds BYPASSRLS. Row-level security does not apply `
475
+ + 'to it, so every partner boundary in this schema is inert. The application must '
476
+ + 'connect as a role that owns nothing and has no BYPASSRLS (frozen spec §3); only the '
477
+ + 'migration and backup roles may hold it.');
478
+ }
474
479
  }
475
480
  }
476
481
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aria-framework/db-worker",
3
- "version": "0.27.1",
3
+ "version": "0.27.2",
4
4
  "description": "Aria App Framework — db-worker module. Async RPC bridge over synchronous better-sqlite3: a worker-thread dispatcher (runWorker), a main-thread client with per-call timeouts and crash handling (DbClient), and a SQLite layer with WAL pragmas + a numbered-migration runner (database).",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -40,7 +40,7 @@
40
40
  "pg": "^8.23.0"
41
41
  },
42
42
  "scripts": {
43
- "test": "node test/driverContract.js && node test/migrations.js && node test/migrations-notx.js && node test/migrationDialect.js && node test/regressions.js && node test/transactions.js && node test/tenantContext.js && node test/tenancyMigration.js && node test/tenancyAttribution.pglite.js && node test/tenancyNullable.pg.js && node test/tenancyPartnerFk.pg.js && node test/tenancyOnUpdate.pg.js && node test/dialectIntrospection.js && node test/tenantRls.pg.js && node test/nestedTransaction.pg.js && node test/clientError.pg.js && node test/migrationRole.pg.js && node test/smoke.js && node test/tier2.js && node test/timezone.pg.js && node test/pinPoolUtc.js && node test/pinAwaited.pg.js",
43
+ "test": "node test/driverContract.js && node test/migrations.js && node test/migrations-notx.js && node test/migrationFailureSurfaces.js && node test/migrationDialect.js && node test/regressions.js && node test/transactions.js && node test/tenantContext.js && node test/tenancyMigration.js && node test/tenancyAttribution.pglite.js && node test/tenancyNullable.pg.js && node test/tenancyPartnerFk.pg.js && node test/tenancyOnUpdate.pg.js && node test/dialectIntrospection.js && node test/tenantRls.pg.js && node test/nestedTransaction.pg.js && node test/clientError.pg.js && node test/migrationRole.pg.js && node test/smoke.js && node test/tier2.js && node test/timezone.pg.js && node test/pinPoolUtc.js && node test/pinAwaited.pg.js",
44
44
  "prepublishOnly": "node ../../test/packaging.js db-worker"
45
45
  }
46
46
  }