chore: dynamic ports in dev-mode#164
Closed
atilafassina wants to merge 4 commits intomainfrom
Closed
Conversation
8a7d0f9 to
41d963d
Compare
Dev server tries the preferred port (DATABRICKS_APP_PORT or 8000) and on EADDRINUSE retries on port 0 when no explicit pin is provided. Explicit pins (env or `port` config) and non-EADDRINUSE bind errors always throw, so prod and pinned dev never silently drift. Co-authored-by: Isaac Signed-off-by: Atila Fassina <atila@fassina.eu>
In dev, DATABRICKS_APP_PORT=N now means "try N first." If N is busy,
warn and fall back to an OS-assigned port. A code-level
`server({ port })` config remains a strict pin (throws on EADDRINUSE).
Co-authored-by: Isaac
Signed-off-by: Atila Fassina <atila@fassina.eu>
a641d4b to
a29e8ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The dev server prefers port
8000(orDATABRICKS_APP_PORTif set) and falls back to an OS-assigned free port onEADDRINUSEwhenever it's in dev mode without a code-levelportpin. This lets a secondpnpm devstart without colliding with an already-running one.DATABRICKS_APP_PORTis treated as a preference in dev (warns and falls back if busy). A code-levelserver({ port })is a strict pin (throws onEADDRINUSE) so explicit configuration choices aren't masked. Prod is always strict.Behavior matrix
DATABRICKS_APP_PORTset by platform)EADDRINUSE→ throw.8000.EADDRINUSE→ warn → bind OS-assigned port.DATABRICKS_APP_PORT=80018001.EADDRINUSE→ warn → bind OS-assigned port.server({ port: 3000 })3000.EADDRINUSE→ throw.EADDRINUSEerrorThe actually-bound port is logged via
server.address()so the OS-assigned port is visible to the developer.Test plan
pnpm test— all suites passpnpm typecheck— cleanpnpm check— clean8000)pnpm devinstances simultaneously; the second warns and binds a different port; the bound port is visible in the startup log