Skip to content

fix: harden PostgreSQL failure boundaries - #17

Merged
smiggleworth merged 3 commits into
mainfrom
issues/15-16-postgres-robustness
Aug 15, 2026
Merged

fix: harden PostgreSQL failure boundaries#17
smiggleworth merged 3 commits into
mainfrom
issues/15-16-postgres-robustness

Conversation

@smiggleworth

@smiggleworth smiggleworth commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • observe every checked-out PostgreSQL client and normalize socket failures instead of allowing unhandled process events
  • discard failed clients and preserve the original failure across best-effort rollback cleanup
  • cap insertMany and upsertMany chunks by both configured rows and PostgreSQL's 65,535 bind-parameter limit
  • add real PostgreSQL connection-kill and 70-column batch regressions

Linked issues

Closes #15
Closes #16

TDD

  • Red 26f5b31: the child process crashes on unhandled 57P01; the real 70,000-bind insert fails with PostgreSQL 08P01; generated insert/upsert queries each contain all 70,000 values.
  • Green 488412d: checked-out client observation converts the error to a catchable connection DatabaseError, while protocol-aware batching produces two safe statements for each bulk operation.

Guardrails

  • real child process with pg_terminate_backend() during an idle transaction
  • fast listener lifecycle and normalization unit test
  • deterministic exact parameter-count assertions for insert and upsert
  • real 70-column, 1,000-row insert and upsert
  • PostgreSQL 16, 17, and 18 hosted integration matrix

Acceptance audit

Local verification

  • npm run check
  • ASKR_ORM_TEST_DATABASE_URL=... npm run test:integration
  • npm audit --omit=dev

@smiggleworth
smiggleworth marked this pull request as ready for review August 15, 2026 19:09
Copilot AI lite review requested due to automatic review settings August 15, 2026 19:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@smiggleworth
smiggleworth merged commit bf6d7fd into main Aug 15, 2026
4 checks passed
@smiggleworth
smiggleworth deleted the issues/15-16-postgres-robustness branch August 15, 2026 19:09
@smiggleworth

Copy link
Copy Markdown
Contributor Author

Release closure:

  • PR fix: harden PostgreSQL failure boundaries #17 squash-merged as bf6d7fd057855cbcc8e726136b0dd88bf686dd56.
  • Publish run 31903111492 passed the full package and PostgreSQL 16/17/18 gates before publishing: https://github.com/askrjs/askr-orm/actions/runs/31903111492
  • Annotated tag v0.0.2 resolves to the exact squash commit.
  • npm serves @askrjs/orm@0.0.2 with integrity sha512-B+JJ7B8zFVZo2yPoQyEv0xcnfb/rtpuvDC1Et8LBu3c879v1gvCvedsl6nfLnnUTj9RPiwLcuPlTaUH0dMnjPQ==.
  • A clean registry-only consumer connected the published package to PostgreSQL 18, terminated a checked-out transaction backend, caught DatabaseError { category: "connection", code: "57P01" }, then inserted and upserted all 1,000 rows of a 70-column table.
  • The clean consumer reported zero runtime audit vulnerabilities. Its temporary PostgreSQL container was stopped and removed after verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants