Skip to content

fix: pushkin-prep should gracefully handle containers already existing and non-Pushkin templates#372

Open
cherriechang wants to merge 1 commit intomainfrom
fix/prep-graceful-handle-container-exist
Open

fix: pushkin-prep should gracefully handle containers already existing and non-Pushkin templates#372
cherriechang wants to merge 1 commit intomainfrom
fix/prep-graceful-handle-container-exist

Conversation

@cherriechang
Copy link

1) Failing for existing container
When running pushkin-dev prep with existing database containers from a previous run, the command would fail with a misleading "password authentication failed" error. This happened because the existing containers were using different credentials than the current pushkin.yaml config.

This commit implements Option 1 from the issue: automatic detection and cleanup of stale database containers.

Changes:

  • Added ensureCleanState() function that checks for existing database containers before setup
  • If containers exist, displays a warning and removes them cleanly
  • Uses docker ps -a to detect both running and stopped containers
  • Follows the same pattern as killLocal() using compose.stop() and compose.rm()
  • Includes proper error handling to avoid failing the entire setup

Benefits:

  • Makes prep command idempotent - safe to run multiple times
  • Eliminates confusing password authentication errors
  • Improves developer experience by avoiding manual cleanup steps
  • No waiting through 10 failed connection attempts (~2+ minutes)

Fixes pushkin-dev prep fails cryptically when database containers already exist

2) Failing for non-Pushkin site templates

When running `pushkin-dev prep` with existing database containers from a
previous run, the command would fail with a misleading "password
authentication failed" error. This happened because the existing containers
were using different credentials than the current pushkin.yaml config.

This commit implements Option 1 from the issue: automatic detection and
cleanup of stale database containers.

Changes:
- Added `ensureCleanState()` function that checks for existing database
  containers before setup
- If containers exist, displays a warning and removes them cleanly
- Uses `docker ps -a` to detect both running and stopped containers
- Follows the same pattern as `killLocal()` using compose.stop() and
  compose.rm()
- Includes proper error handling to avoid failing the entire setup

Benefits:
- Makes `prep` command idempotent - safe to run multiple times
- Eliminates confusing password authentication errors
- Improves developer experience by avoiding manual cleanup steps
- No waiting through 10 failed connection attempts (~2+ minutes)

Fixes pushkin-dev prep fails cryptically when database containers already exist
@changeset-bot
Copy link

changeset-bot bot commented Nov 24, 2025

⚠️ No Changeset found

Latest commit: 7465a5f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cherriechang cherriechang self-assigned this Nov 24, 2025
@cherriechang cherriechang added the bug Something isn't working label Nov 24, 2025
@cherriechang cherriechang changed the title Fix: Auto-cleanup existing database containers before running prep Fix prep to gracefully handle containers already existing and non-Pushkin templates Nov 24, 2025
@cherriechang cherriechang added the pushkin-cli Relates to the CLI label Nov 24, 2025
@cherriechang cherriechang changed the title Fix prep to gracefully handle containers already existing and non-Pushkin templates fix: pushkin-prep should gracefully handle containers already existing and non-Pushkin templates Nov 24, 2025
@becky-gilbert
Copy link

@cherriechang I've been hitting this issue while reviewing #373, so it would be nice to merge this ASAP! Is it ready for review?

@cherriechang
Copy link
Author

cherriechang commented Feb 6, 2026

@cherriechang I've been hitting this issue while reviewing #373, so it would be nice to merge this ASAP! Is it ready for review?

I think so!

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

Labels

bug Something isn't working pushkin-cli Relates to the CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pushkin prep fails for non-Pushkin site templates pushkin prep hangs when docker containers are not built properly

3 participants