Context
src/selfhost/d1-adapter.ts:75-90's batch() wraps its ROLLBACK in its own try/catch { /* ignore */ } specifically so a failing rollback can never suppress the original error being re-thrown. src/selfhost/pg-adapter.ts:65-78's batch() calls await client.query("ROLLBACK") unguarded in the catch block — if the rollback itself throws (plausible exactly when the original error was a connection failure), that new error propagates instead of throw error, silently discarding the real cause.
Requirements
- Wrap
pg-adapter.ts's rollback call in the same defensive try/catch { /* ignore */ } the SQLite adapter already uses, so the original error is always the one that surfaces.
- Do not change the SQLite adapter — it's already correct.
Test Coverage Requirements
This file is exempt from Codecov's unit-coverage requirement (validated by the real-Postgres integration test per codecov.yml) — but add a targeted test in test/integration/selfhost-pg.ts (gated on PG_TEST_URL) simulating a rollback failure and confirming the original error still surfaces.
Deliverables
Expected Outcome
A batch failure on Postgres always surfaces its real cause, matching the SQLite adapter's existing guarantee.
Links & Resources
src/selfhost/pg-adapter.ts:65-78, src/selfhost/d1-adapter.ts:75-90
Context
src/selfhost/d1-adapter.ts:75-90'sbatch()wraps itsROLLBACKin its owntry/catch { /* ignore */ }specifically so a failing rollback can never suppress the original error being re-thrown.src/selfhost/pg-adapter.ts:65-78'sbatch()callsawait client.query("ROLLBACK")unguarded in thecatchblock — if the rollback itself throws (plausible exactly when the original error was a connection failure), that new error propagates instead ofthrow error, silently discarding the real cause.Requirements
pg-adapter.ts's rollback call in the same defensivetry/catch { /* ignore */ }the SQLite adapter already uses, so the original error is always the one that surfaces.Test Coverage Requirements
This file is exempt from Codecov's unit-coverage requirement (validated by the real-Postgres integration test per
codecov.yml) — but add a targeted test intest/integration/selfhost-pg.ts(gated onPG_TEST_URL) simulating a rollback failure and confirming the original error still surfaces.Deliverables
pg-adapter.ts'sbatch()rollback failure no longer masks the original error.Expected Outcome
A batch failure on Postgres always surfaces its real cause, matching the SQLite adapter's existing guarantee.
Links & Resources
src/selfhost/pg-adapter.ts:65-78,src/selfhost/d1-adapter.ts:75-90