Why a Committed PostgreSQL Write Can Still Produce a Failed Node.js Response

A PostgreSQL commit can succeed even when the Node.js response never reaches the client. That delivery failure does not undo the order. This short shows the unsafe catch-and-rollback pattern, then the structural fix: persist the order and its replay record in one transaction before attempting response delivery. Retries must reuse the same key, scoped to a verified caller and operation. Changed request semantics must be rejected. The guarantee is limited to at most one committed local business operation per scoped key while its record is retained. It is not exactly-once HTTP delivery or atomicity for external side effects. Code is schematic, not a complete handler. Key claiming, concurrency control, validation, fingerprinting, and full transaction error handling are covered in the write-up. This short focuses on acknowledged commits followed by failed delivery, not unknown commit outcomes. Full walkthrough and local failure test: https://hackyjs.com/posts/why-a-committed-postgresql-write-can-still-produce-a-failed-nodejs-response

nodejspostgresqlidempotencydatabase-transactionsbackend

Read the post →