Repository navigation
Require a response, not just a connect, to call an app running - #11
Merged
Merged
Conversation
appRunning was true for every project with a port assigned. The probe was a
bare TCP connect to 127.0.0.1:<port>, but appx publishes the whole app port
range (10000-10199) from the outer container, so one docker-proxy process
accepts on every port in the range whether or not anything is behind it. It
completes the handshake and only resets once the client writes, so the probe
could never return false.
portServing now writes a minimal HEAD request and waits for a reply. Only a
reset or an EOF *before any response* counts as down; a read timeout counts
as up, because a listener that accepted the request and has not answered yet
is still a listener. That bias is deliberate — a transiently slow app should
not flicker to "not running". Probing with HTTP is safe because appx only
ever reverse-proxies HTTP to these ports, so every app on them is an HTTP
server by construction.
Also closes the devPort gap from the same issue: only AssignedPort was
probed, so a project whose DEV server was the running one looked identical
to one running nothing. Check now returns a Health{App, Dev} per project and
the API reports devRunning alongside appRunning. The frontend follows the
distinction it already implied — the preview iframe (which targets the DEV
subdomain) is gated on devRunning, "Open App" (PROD) on appRunning, and the
dashboard card distinguishes DEV RUNNING from RUNNING.
maxConcurrentDials goes 20 -> 64 since a sweep now costs two probes per
project. No result cache: a 30-project sweep with every port probed measures
~10ms, so there is nothing to amortise yet.
Fixes #8
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Fixes #8.
The problem
appRunningwastruefor every project with a port assigned. The probe was a bare TCP connect, but appx publishes the whole app port range from the outer container, so onedocker-proxyprocess accepts on every port in the range regardless of what is behind it — it completes the handshake and only resets once the client writes.Verified against a real
docker-proxy(not a fake):The fix
portServingwrites a minimalHEADrequest and waits for a reply:A timeout counting as up is deliberate: a transiently slow app should not flicker to "not running". The only false-negative shape left is a server that closes without replying at all, which no HTTP server does. Probing with HTTP is safe because appx only ever reverse-proxies HTTP to these ports (
router.godialshttp://127.0.0.1:<port>), so every app on them is an HTTP server by construction.The devPort gap
The issue's secondary point: only
AssignedPortwas probed, so a project whose DEV server was the running one was indistinguishable from one running nothing.Checknow returnsHealth{App, Dev}per project and the API reportsdevRunningalongsideappRunning. The frontend follows the distinction it already implied:-devsubdomain) → gated ondevRunning(wasappRunning)appRunningRUNNING/DEV RUNNING/NOT STARTEDCost
maxConcurrentDials20 → 64, since a sweep is now two probes per project. No result cache — the issue suggested considering one, but a 30-project sweep with every port probed measures ~10ms, so there is nothing to amortise. Easy to add later if the range fills up.Testing
Unit tests reproduce the docker-proxy shape in-process (
acceptThenClose, both graceful FIN and RST):TestHealthChecker_PublishedPortWithNothingBehindIt— the regression testTestHealthChecker_RespondingServer/_SilentListenerIsUp— both up-verdictsTestHealthChecker_DevPortProbedSeparately— DEV up, PROD emptyTestGetProject_ReportsDevAndProdSeparately— API shapePlus
dockerproxy_manual_test.go, an env-gated manual test against a real container (skipped by default; the setup command is in its doc comment). In-process fakes can only approximatedocker-proxy, so this pins the real thing:Happy to drop that file if you'd rather not carry a skipped test.
End-to-end through the real binary, with a project pointed at the published-but-empty port 10502 and a dev server on 10600:
Both rows reported
appRunning=truebefore this change. Driving the UI with Playwright: the dashboard showsdevonlyas DEV RUNNING andnothingas NOT STARTED; the project page shows the DEV badge, keeps the preview pane (iframe renders the dev app through the-devsubdomain proxy), and correctly omits the "Open App" link that previously pointed at a PROD port with nothing behind it.task build,task test,task lintpass.🤖 Generated with Claude Code