feat: add debug-mode enhanced error handling for PostgreSQL transaction failures #122
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: add debug-mode enhanced error handling for PostgreSQL transaction failures
Summary
This PR adds comprehensive debug-mode error handling enhancements to help developers troubleshoot PostgreSQL transaction failures, particularly the common "current transaction is aborted" (error code 25P02) scenario. All enhancements are only active when
LAUNCHQL_DEBUG=trueorNODE_ENV=developmentto avoid any performance impact in production.Key changes:
MigrationErrorutility class for contextual error informationexecuteQueryandwithTransactionwith debug context and better 25P02 handlingReview & Testing Checklist for Human
process.env.LAUNCHQL_DEBUG === 'true' || process.env.NODE_ENV === 'development'logic works correctly and consistently across all modified filesdebug-schema.sqlapply correctly and thedebug_mode_enabledtable is created properlyRecommended test plan:
LAUNCHQL_DEBUG=trueDiagram
%%{ init : { "theme" : "default" }}%% graph TD Client["packages/core/src/migrate/client.ts"]:::major-edit Transaction["packages/core/src/migrate/utils/transaction.ts"]:::major-edit Deploy["packages/core/src/projects/deploy.ts"]:::major-edit Procedures["packages/core/src/migrate/sql/procedures.sql"]:::major-edit Errors["packages/core/src/migrate/utils/errors.ts"]:::major-edit DebugSchema["packages/core/src/migrate/sql/debug-schema.sql"]:::major-edit Index["packages/core/src/index.ts"]:::minor-edit Client -->|"uses"| Transaction Client -->|"uses"| Errors Deploy -->|"uses"| Client Transaction -->|"executes"| Procedures Client -->|"applies"| DebugSchema Index -->|"exports"| Errors subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
process.env.LAUNCHQL_DEBUG === 'true' || process.env.NODE_ENV === 'development'MigrationErrorclass provides structured error context including change names, project names, SQL queries, and error codesSession info: Requested by Dan Lynch (@pyramation) - Devin session