Skip to content

fix: close migration CLI db clients on failure paths#143

Merged
danceroutine merged 5 commits into
mainfrom
fix/cli-db-cleanup
Jun 5, 2026
Merged

fix: close migration CLI db clients on failure paths#143
danceroutine merged 5 commits into
mainfrom
fix/cli-db-cleanup

Conversation

@danceroutine

Copy link
Copy Markdown
Owner

Summary

  • Wrap migrate and status CLI handlers in try/finally so dbClient.close() always runs, even when runner.apply() or runner.status() throws.
  • Aligns with the existing connectAndIntrospect() pattern in the same file.
  • Adds regression tests that mock MigrationRunner failures and assert the CLI client is closed.

Why

On failure paths (SQL errors, checksum mismatches, invalid migration modules), the CLI previously skipped close() and could leak database connections.

Test plan

  • pnpm --filter @danceroutine/tango-migrations test
  • pnpm --filter @danceroutine/tango-migrations typecheck

Wrap migrate and status handlers in try/finally so dbClient.close() runs
when runner.apply() or runner.status() throws, matching connectAndIntrospect().

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9183c8dd53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/migrations/src/commands/cli.ts Outdated
Log close failures instead of letting them replace the primary migrate or
status error. Add changeset and regression tests for the dual-failure path.
State the migrate/status failure behavior in outcome language and remove
contrastive implementation phrasing from the patch note.
@danceroutine danceroutine enabled auto-merge (squash) June 5, 2026 15:50
@danceroutine danceroutine merged commit 50692c5 into main Jun 5, 2026
8 checks passed
@danceroutine danceroutine deleted the fix/cli-db-cleanup branch June 5, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant