Skip to content

fix(selfhost): Postgres adapter's batch() rollback can mask the original error, unlike the SQLite adapter #6282

Description

@JSONbored

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

  • pg-adapter.ts's batch() rollback failure no longer masks the original error.
  • Integration test for the scenario.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions