feat(pgpm/core): add smart error output collapsing and limiting #599
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.
Summary
Reduces verbosity of error output when migrations fail with many
pgpm_migrate.deploycalls. Previously, a failed deployment with 1600+ migrations would output 1600+ lines of query history. Now, consecutive identical queries are collapsed into a summary showing the range, count, and first/last change names.Key changes:
PGPM_ERROR_QUERY_HISTORY_LIMIT(default: 30 queries)PGPM_ERROR_MAX_LENGTH(default: 10000 chars)PGPM_ERROR_VERBOSE=trueto disable all limiting@pgpmjs/envand@pgpmjs/typesReview & Testing Checklist for Human
PGPM_ERROR_VERBOSE=trueshows full output, and that the limit vars work as expectederrors.tsfile is properly separated fromtransaction.tsand imports work correctlyRecommended test plan:
cd pgpm/core && pnpm test -- error-output-formattingPGPM_ERROR_VERBOSE=trueand verify full output is shownNotes
pgpm_migrate.deployto extract change names from paramsgetErrorOutputConfig(), so changes require process restartextractDeployChangeNamefunction assumesparams[1]is the change name - this matches the current pgpm_migrate.deploy signatureUpdates since last revision
ErrorOutputOptionsinterface to@pgpmjs/types, addederrorOutputtoPgpmOptionsandpgpmDefaults, added env var parsing in@pgpmjs/env, updatedtransaction.tsto usegetErrorOutputConfig()instead of directprocess.envaccesspgpm/envto include the newerrorOutputfield ingetEnvVars()return valueerrors.tsfile, keepingtransaction.tsfocused on transaction lifecycle. Functions are re-exported fromtransaction.tsfor backward compatibility.Link to Devin run: https://app.devin.ai/sessions/c634626524714b3596c4d506d7f94a9a
Requested by: Dan Lynch (@pyramation)