Repository navigation
Conversation
@wasp/spec
@wasp/cli
@wasp/cli-darwin-arm64-unknown
@wasp/cli-linux-arm64-glibc
@wasp/cli-linux-x64-glibc
@wasp/cli-linux-x64-musl
commit: |
08489d4 to
fc8f764
Compare
Deploying wasp-docs-on-main with
|
| Latest commit: |
5bdb821
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b5525535.wasp-docs-on-main.pages.dev |
| Branch Preview URL: | https://issue-4479-foreground-db.wasp-docs-on-main.pages.dev |
fc8f764 to
4b5b7ce
Compare
4b5b7ce to
499bda2
Compare
9115c43 to
f649d3b
Compare
f649d3b to
90179ba
Compare
90179ba to
5881a04
Compare
b681c8a to
7741f7c
Compare
| getDatabaseForSession (ReusedDatabase db) = db | ||
| getDatabaseForSession (StartedDatabase db _ _) = db | ||
|
|
||
| additionalInfoLines :: Dev.Postgres.DevDbSpec -> [String] |
There was a problem hiding this comment.
Moved unchanged out of startPostgresDevDb.
| dbDockerImage = fromMaybe (fst defaultPostgresDockerImageSpec) options.dbImage | ||
| dbDockerVolumeMountPath = fromMaybe (snd defaultPostgresDockerImageSpec) options.dbVolumeMountPath | ||
|
|
||
| resolveDevDbPort :: Command PortNumber |
There was a problem hiding this comment.
Same port selection, now reads options.dbPort.
| Docker.stopDatabase containerId `finally` (liftIO (cancel databaseJob) `finally` Docker.removeContainer containerId) | ||
| release _ = return () | ||
|
|
||
| preparePostgresDevDb :: Path' Abs (Dir WaspProjectDir) -> String -> DbStartOptions -> DatabaseStartPolicy -> Command PreparedDatabase |
There was a problem hiding this comment.
Based on startPostgresDevDb. Now chooses whether to start or reuse the database.
| throwIfExeIsNotAvailable | ||
| "docker" | ||
| "To run PostgreSQL dev database, Wasp needs `docker` installed and in PATH." | ||
| startPostgresDevDb :: Path' Abs (Dir WaspProjectDir) -> String -> DbStartOptions -> Command () |
There was a problem hiding this comment.
Now waits for PostgreSQL to be ready, cleans up on exit, and reports container exits as errors.
| import qualified Wasp.Message as Msg | ||
| import Wasp.Util.Docker (DockerImageName) | ||
|
|
||
| ensureDockerDaemonAvailable :: Command () |
There was a problem hiding this comment.
Docker helpers moved here.
There was a problem hiding this comment.
From where? I can't find these functions anywhere else in the changelog.
There was a problem hiding this comment.
Bad wording on my part, we moved throwIfExeIsNotAvailable for docker from start dev DB here, but also added some new Docker helpers.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed b3b9567, the behavioral change since the last incremental pass at 761f5fc, with the full PR diff as context.
- Removed the application-database readiness dependency: Replaced the application DB query with
pg_isreadyagainstpostgres, preserving the published-port check and allowing Prisma to recreate a missing managed database. - Added recovery coverage: Added a Docker scenario that drops the application database before both migration and reset, then checks container ownership and cleanup behavior.
The earlier readiness finding is addressed and its thread is resolved. PostgreSQL's documented pg_isready contract supports the new check. The new regression scenario could not be executed here: ./run test:waspc:e2e failed before compilation with Error: [Cabal-7107], unknown package: with-utf8; Docker also reported Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the readiness simplification in 3e7a627, following the naming-only change in d54bd41, with the full PR diff as context.
- Simplified readiness polling: Removed the separate published-host-port probe and retried the in-container PostgreSQL TCP readiness check directly, preserving missing-application-database recovery.
- Clarified readiness names: Renamed the private readiness helpers and local result to distinguish PostgreSQL availability from host-port reachability before removing the latter check.
Checked Docker startup ordering and the official PostgreSQL image's socket-only initialization server; no concrete startup regression was identified. Docker integration tests could not run: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Haskell tests were not rerun in this pass.
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
Important
Concurrent commands can now share an automatically started database without coordinating its lifetime, allowing one command to stop PostgreSQL while another still needs it.
Reviewed changes Reviewed the integration with the new compilation-locking model since the previous review at 3e7a627, using the complete PR diff for context.
- Adapted DB command locking: Removed the session-wide project lock and used
waitEnsureCompileto prepare generated code before running database actions. - Preserved watcher integration: Kept automatic database startup inside
wasp start's watcher lock and retained the database URL in startup output.
Docker integration verification was blocked: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? The concurrency finding is based on the command-admission and cleanup paths; Haskell tests were not rerun.
gpt-6.1-sol | 𝕏
sodic
left a comment
There was a problem hiding this comment.
I thought about the current system and have two main reservations. You'll know the two important comments when you see them :)
| import qualified Wasp.Message as Msg | ||
| import Wasp.Util.Docker (DockerImageName) | ||
|
|
||
| ensureDockerDaemonAvailable :: Command () |
There was a problem hiding this comment.
From where? I can't find these functions anywhere else in the changelog.
| import Wasp.Cli.Command.BuildStart (buildStart) | ||
| import qualified Wasp.Cli.Command.Call as Command.Call | ||
| import Wasp.Cli.Command.Clean (clean) | ||
| import Wasp.Cli.Command.Compile (compileCommand) |
There was a problem hiding this comment.
Some questions wrt the description. Ill ask them here so it's easier to reply
It doesn't auto-start the DB if it's already running or DATABASE_URL is specified
Does it say so?
There was a problem hiding this comment.
Yep, we tell the user that an existing database is being re-used: https://github.com/wasp-lang/wasp/pull/4914/changes#diff-6182f0f334b5da445bca499168fbce953b42cf12f426457075c6ffdabfb3e94fR241
| retry pauseStrategy maxNumRetries = retryWithCallback pauseStrategy maxNumRetries (\_ _ -> pure ()) | ||
|
|
||
| -- | Repeats a check until it returns True or the retries are exhausted. | ||
| retryUntil :: (MonadRetry m) => PauseStrategy -> Natural -> m Bool -> m Bool |
There was a problem hiding this comment.
Why does this return a boolean? I'd expect the return type to match retry, otherwise we are losing information, right?
There was a problem hiding this comment.
This is for the case where we don't care about the result or failure. We just want to wait until an action finishes and wonder if it succeeds. It's a specialization of retry above and I think it's fine if it gives you less information - you opt into that by using this 🤷♂️
There was a problem hiding this comment.
Compare:
ready <- Retry.retryUntil (Retry.constPause 1000000) 59 $ isPostgresAcceptingConnections devDbSpec
unless ready $ do
(_, output, errors) <- readProcessWithExitCode "docker" ["logs", "--tail", "30", devDbSpec.dockerContainerName] ""
ioError $ userError $ printf "PostgreSQL did not become ready. Check the logs below, then try again.\n%s%s" output errorsvs.
Retry.retry (Retry.constPause 1000000) 59 (checkPostgresAcceptsConnections devDbSpec) >>= \case
Right () -> return ()
Left _ -> do
(_, output, errors) <- readProcessWithExitCode "docker" ["logs", "--tail", "30", devDbSpec.dockerContainerName] ""
ioError $ userError $ printf "PostgreSQL did not become ready. Check the logs below, then try again.\n%s%s" output errorsI found that it improved readability for me.
| start :: Arguments -> Command () | ||
| start = withArguments startArgsParser $ \args -> | ||
| ProjectLock.acquireWatcher $ \projectLock -> do | ||
| ProjectLock.acquireWatcher $ \projectLock -> Start.Db.withDevDb args.dbStartOptions $ \managedDb -> do |
There was a problem hiding this comment.
If the database is a "proper component" of an app, along the server and the client, why does it get special treatment with this decorator? We don't do withDevServer and withDevClient.
I'd expect the database to be started in the same way the client and server are started.
| " --create-only", | ||
| " --db-port <port>", | ||
| " --db-image <image>", | ||
| " --db-volume-mount-path <path>" | ||
| ], | ||
| cmd " studio GUI for inspecting your database.", | ||
| "", | ||
| title "DATABASE OPTIONS", | ||
| " --db-port <port> Host port when starting managed PostgreSQL.", | ||
| " --db-image <image> Docker image when starting managed PostgreSQL.", | ||
| " --db-volume-mount-path <path>", | ||
| " Data path inside a new PostgreSQL container.", | ||
| " These options also work with reset, seed, migrate-dev, and studio.", | ||
| "", |
There was a problem hiding this comment.
We have some repetition here. Can we do something about that? RAW
| "migrate-dev" : optionalMigrateArgs -> runCommand $ withArguments Command.Db.Migrate.migrateArgsParser Command.Db.Migrate.migrateDev optionalMigrateArgs | ||
| "seed" : seedArgs -> runCommand $ withArguments Command.Db.Seed.seedArgsParser Command.Db.Seed.seed seedArgs | ||
| "studio" : studioArgs -> runCommand $ withArguments (ArgsParser "wasp db studio" (pure ())) (const Command.Db.Studio.studio) studioArgs | ||
| "reset" : resetArgs -> runCommandThatRequiresDbRunning Command.Db.Reset.resetArgsParser Command.Db.Reset.reset resetArgs |
There was a problem hiding this comment.
If I got it right, we lose this thing later, right?
There was a problem hiding this comment.
Nope, this is the final form. It's a useful helper that adding parser options that configure the dev database + it ensures the dev database is running.
| let databaseUrlLine = case managedDb of | ||
| Nothing -> "" | ||
| Just db -> printf " ℹ Database: %s\n" (Dev.Postgres.getDevConnectionUrl db) | ||
| cliSendMessageC $ Msg.Info $ showRunConfigUrls runConfigs <> databaseUrlLine |
There was a problem hiding this comment.
Hm, something smells here. Similarly to the decorator, it's strange to see that the database has its own special handling.
I am guessing this is the explanation: #4914 (comment)
If so, I suggest we start with that refactor, not the other way around. So:
- First, we figure out how to make the database a first-class component of our apps (or as close as possible). Not an extra weird dragon next to the server and the client. Do do this, we'll have to untangle the current mess of abstractions and adapt existing commands to fit that.
- Then we add the new functionality to Wasp start. If database is an equal/first-class component. It should be easy and straightforward.
I think this is the way to go because it will clean up the relationship between different app components and will make most future things much easier (deployment, swapping parts, starting up parts independently, everything).
There was a problem hiding this comment.
This is def the worst fitting code. It super special handling of database next to client and server. I agree!
Carlos started working on unifying client + server + db into the run configs here: #5130
I'll ask him if we can push that work first, so I can have a better case.
| data DbStartOptions = DbStartOptions | ||
| { dbPort :: Maybe PortNumber, | ||
| dbImage :: DockerImageName, | ||
| dbVolumeMountPath :: DockerVolumeMountPath | ||
| dbImage :: Maybe DockerImageName, | ||
| dbVolumeMountPath :: Maybe DockerVolumeMountPath | ||
| } | ||
| deriving (Eq, Show) | ||
|
|
||
| dbStartOptionsParser :: Opt.Parser DbStartOptions | ||
| dbStartOptionsParser = |
There was a problem hiding this comment.
Since this is now a general thing shared by two commands, and since wasp start is not implemented as "just run wasp db start on the side, I believe these deserve both a new name and a new location. I'm guessing that's what happens here: Startup changes stay here. The module moves are in #5064.
In case you haven't, please check if there's precedent on how we handle these things in the codebase (i.e., arguments that are shared between commands).
In the future, if possible, I'd do the move first and then add the stuff. I know it's not practical most of the time because of the way a system evolves, so no worries.
Now the more important question, could we share more of the functionality between the two commands? I'd expect it to be more modular, like this:
Current system
The current system only supports running the commands independently: first run wasp start db and then run wasp start.
Option 1 - Running the commands independently:
- User runs
wasp start db. - Wasp runs the
startDatabaseProcedure. - User runs
wasp start. - Wasp does the
startClientAndServerProcedure. - Internally, the
startClientAndServerProcedurepicks up the already running dev database.
New system
The new system supports both running the commands independently and running a bundled command.
Option 1 - Running the commands independently -> Same as before, no changes.
Option 2- Running the bundled command:
- User runs
wasp start. - Wasp runs the
startDatabaseProcedure. - Wasp does the
startClientAndServerProcedure. - Internally, the
startClientAndServerProcedurepicks up the already running dev database.
The only change I expected is that wasp starts gets the second step. The last two steps should work as they always have.
There was a problem hiding this comment.
What's this? We haven't done anything with the migrations, right?
There was a problem hiding this comment.
All database commands now get their options + dev database options. But it's a silly test to add as it tests the parser library, I think my guard was down here for "is this really needed" question. Dropping it!
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the merge integration in a0993d9 since the last incremental pass at 5dc4db8, along with the comment-only change since the prior substantive Pullfrog review.
- Reused the shared Docker daemon check: Database startup now calls
checkDockerDaemonConnection, retaining the executable check and providing the upstream daemon-start guidance and Docker error details. - Preserved upstream CLI integration: Retained the
legacyVersionsNoteimport required by the updated installation guidance. - Expanded test-helper documentation: Explained why database tests stop PostgreSQL directly and wait for Wasp cleanup.
Validation was static; tests were not rerun in this pass.
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the merge integration in 7baa976 since the prior Pullfrog review at a0993d9.
- Adapted database jobs: Migrated image pulling, attached PostgreSQL execution, and Studio to the upstream
JobAPI, removing the custom Docker output reader while retaining lifecycle cleanup. - Restored interrupted-start recovery: Removed stale stopped containers before creation without force-removing running databases.
- Integrated signal-cleanup coverage: Added an isolated SIGINT/SIGTERM scenario with a live database session and stale-container restart, and updated process matching for
docker start --attach.
Validation: all 55 CLI tests and 686 compiler/unit tests passed. cabal build waspc-e2e-tests wasp-cli succeeded. Docker integration tests could not run because Docker reported Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
gpt-6.1-sol | 𝕏
|
@sodic I'm taking this over from Carlos: #5130 This drops the double analysis caveat I mentioned in the body (yay!) and moves the database into the runtime config (moving it closer to being a proper component). I know you'd want the database not to be special but there are some reasons for it still needing a bit of different handling:
This gives is a sort of different lifecycle than server + client. On the other note, the system is built so that |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the rewritten incremental delta on the new database-lifecycle base, including the narrowed automatic-start scope.
- Reused shared database lifecycle handling: Wrapped
wasp startcompilation and runtime in managed PostgreSQL startup, while leaving custom databases, SQLite, and already-running containers alone. - Preserved compilation diagnostics: Added preliminary analysis for database selection and retained normal compilation to report analysis failures; the deliberate duplicate analysis remains documented for a later stack change.
- Updated startup options and output: Composed the database options into
wasp start, displayed managed connection URLs, and updated CLI help, connection guidance, and the changelog. Database commands no longer automatically start PostgreSQL in this version. - Added startup lifecycle coverage: Added a PostgreSQL app-start/SIGINT/container-removal scenario and assigned database ports separately for parallel start tests.
Local CLI test attempts returned [timed out after 120000ms] during tool installation and cold Haskell dependency builds; a background continuation was stopped before tests ran. Docker E2E execution was unavailable: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the delta since b7d1445, focusing on startup ordering and integration with the new migration-check base.
- Removed duplicate analysis: Used the normal compilation's
AppSpecto select the managed database, eliminating the preliminary analysis and helper wrapper. - Moved database startup after compilation: Kept runtime-config construction, connectivity checks, and app execution inside the managed database session.
- Integrated migration warnings: Checked migrations after database startup and retained those warnings for the initial quiet-down output.
Validation was static; Haskell tests were not rerun. Docker E2E verification was unavailable: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
gpt-6.1-sol | 𝕏
|
This pull request is now stale. Next steps if the PR is still relevant, and you are able to devote time to it:
If no action is taken, this PR will be automatically closed in 7 days. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the rebase integration since cd420d1, focusing on database lifecycle and migration-check dependencies now supplied by the base branch.
- Reused upstream database support: Retained automatic startup through the shared lifecycle and database-classification modules, with their Cabal registration and standalone readiness tests preserved upstream.
- Preserved startup ordering and diagnostics: Kept compilation before database startup, migration checks after readiness, and migration warnings in the initial quiet-down output.
Validation was static; tests were not rerun.
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Approach: Sound — starting the managed database between analysis and generation lets setup check migrations without analyzing the project twice.
Reviewed changes Reviewed the incremental changes since b7d1125, focusing on the split-compilation integration and migration diagnostics.
- Split initial compilation: Used
analyzeForCompilationbefore database startup andfinishCompilationinside the managed session, preserving prerequisites and failure cleanup. - Reused setup migration checks: Removed the separate startup check and retained migration warnings through compilation results, quiet-down output, and watcher recompilation.
Validation was static; Haskell and Docker tests were not rerun.
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Approach: Sound — the refreshed base separates database checks from static compilation, so PostgreSQL can start after compilation without duplicate analysis.
Reviewed changes Reviewed the incremental delta since a5e7879, focusing on startup ordering and database diagnostics.
- Completed compilation before database startup: Replaced split analysis/generation with ordinary compilation, leaving compilation failures outside the managed database session.
- Integrated post-start database checks: Checked connectivity and migrations after readiness, preserving database warnings in initial output and the quiet-down buffer.
- Retained session cleanup: Kept runtime configuration, database checks, and app execution inside the owned-container lifetime.
Validation was static; Haskell and Docker tests were not rerun.
gpt-6.1-sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the incremental delta since 89aa2a8, focusing on integration with the refreshed database-check API.
- Updated startup database checks: Kept connectivity validation after readiness and passed the resolved run-config database URL directly to the migration-warning helper.
- Reused shared warning output: Preserved migration warnings in startup output and the quiet-down buffer while adopting
printWarningsIfAny.
Validation was static; Haskell and Docker tests were not rerun.
gpt-6.1-sol | 𝕏

Description
wasp startnow starts the managed PostgreSQL dev database if the app needs one and it isn't running, and stops it on exit.It skips starting one when the app uses SQLite,
DATABASE_URLis set, or the database is already running. In that last case it waits for the database to accept connections and leaves it running on exit.wasp starttakes the same--db-port,--db-imageand--db-volume-mount-pathflags aswasp start db.Part of #4479.
Agreement
Type of change
Checklist
I tested my change in a Wasp app to verify that it works as intended.
🧪 Tests and apps:
examples/kitchen-sink/e2e-tests.waspc/data/Cli/templates, as needed.examples/, as needed.examples/tutorials) I updated the tutorial in the docs (and vice versa).📜 Documentation:
web/docs/.🆕 Changelog: (if change is more than just code/docs improvement)
waspc/ChangeLog.mdwith a user-friendly description of the change.web/docs/migration-guides/.versioninwaspc/waspc.cabalto reflect the changes I introduced.