Make dev app component URLs take explicit ports - #4754
Conversation
The dev URL helpers now take the ports they should use instead of baking in the defaults, so callers pass the ports resolved by findAppComponentPorts. This drops makeDefaultDevRunConfigs and makes wasp db seed and wasp test resolve their ports the same way wasp start does.
@wasp.sh/spec
@wasp.sh/wasp-cli
@wasp.sh/wasp-cli-darwin-arm64-unknown
@wasp.sh/wasp-cli-darwin-x64-unknown
@wasp.sh/wasp-cli-linux-arm64-glibc
@wasp.sh/wasp-cli-linux-x64-glibc
@wasp.sh/wasp-cli-linux-x64-musl
commit: |
There was a problem hiding this comment.
Important
db seed and test client should not require free listening ports when neither command starts an app component.
Reviewed changes in the full initial diff at 360ed1c, covering the explicit-port URL refactor and all updated command paths.
- Explicit URL ports:
makeDevUrlsand its component helpers now require resolvedPortNumbervalues. - Start commands:
wasp startandwasp build startconstruct run configs directly from their selected ports. - Non-serving commands:
wasp db seedandwasp test clientnow probe for free ports before constructing child-process environments. - Run config cleanup: the default development run-config helper was removed in favor of explicit URL construction.
GPT Sol | 𝕏
| appSpec <- analyze waspProjectDir | ||
| let (_, serverRunConfig) = makeDefaultDevRunConfigs appSpec | ||
|
|
||
| ports <- findAppComponentPorts (Nothing, Nothing) |
There was a problem hiding this comment.
Neither this command nor wasp test client binds the selected ports; they only inject the resulting URLs into the child environment. When the defaults are occupied this points seed/test code at unused endpoints, and when the 50-port scan is exhausted it rejects commands that do not need a listening socket, so these non-serving paths should retain deterministic URLs or derive the actual running app URLs instead.
Technical details
# Free-port probing is invalid for non-serving commands
## Affected sites
- `waspc/cli/src/Wasp/Cli/Command/Db/Seed.hs:36-37` — probes for ports, then passes `WASP_WEB_CLIENT_URL`, `WASP_SERVER_URL`, and `PORT` to the Prisma seed process without starting either component.
- `waspc/cli/src/Wasp/Cli/Command/Test.hs:45-46` — performs the same probe before passing `REACT_APP_API_URL` and `PORT` to Vitest, again without binding either port.
- `waspc/cli/src/Wasp/Cli/Port.hs:15-21` — availability is only checked; the returned port is not reserved.
## Required outcome
- `db seed` and `test client` must not fail based on local port availability when they do not listen on those ports.
- Their injected component URLs must describe the intended endpoints rather than newly selected, unserved ports.
Description
Follow-up cleanup to the port-selection work in #4585/#4586. The dev URL helpers in
Wasp.Cli.AppComponentUrlsno longer bake in the default ports:makeDevUrls/makeDevClientUrl/makeDevServerUrlnow take the ports as arguments, so every caller builds its URLs from the ports resolved byfindAppComponentPorts. This removesmakeDefaultDevRunConfigsand the record-update-the-port dance inwasp startandwasp build start, and it makeswasp db seedandwasp testresolve their ports the same waywasp startdoes instead of assuming 3000/3001. Marked as a code improvement since it's a refactor, but note the one behavioural consequence: with awasp startalready occupying 3000/3001,wasp db seedandwasp testwill now pick the next free ports for the URLs they pass to the app (and will fail if no free port exists) rather than silently using the taken defaults.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.