Repository navigation
fix: answer STARTED only once the HTTP endpoint serves - #67
Merged
Merged
Conversation
Start returned STARTED as soon as `uv run uvicorn` was launched. The orchestrator starts dependents on that status, so a dependent could dial the service several seconds before uvicorn bound its port: uvicorn binds only after the app has imported and its lifespan startup has run. Start now waits, bounded, until an HTTP request to the endpoint address Init resolved gets a response (any status). A process that exits first is a failed Start carrying its output; one that never answers is stopped and reported. A bare TCP accept is not used as the signal, because a container runtime's published port is accepted by the engine's proxy before anything listens behind it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
antoinetoussaint-byte
added a commit
that referenced
this pull request
Sep 25, 2026
Moves the core pin from v0.5.8 to v0.5.9 via codefly agent deps --pin v0.5.9, so the release carrying #67 (readiness) builds on the released core. Co-authored-by: Antoine Toussaint <312536060+antoinetoussaint-byte@users.noreply.github.com> Co-authored-by: Claude Opus 5.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.
Summary
StartansweredSTARTEDas soon asuv run uvicornwas launched. The orchestrator starts a service's dependents on that status, so a dependent could dial the service seconds before anything listened. uvicorn binds its port only after the app has imported and its lifespan startup has run.Observed in a local
codefly runof a composition: the CLI reported a python-fastapi model service as running about 3 s before uvicorn listened. A dependent Go service ran its startup embedding-binding check in that window and got:Change
Initrecords the endpoint address it already resolves (net.Address, the native address the host reaches).Startlaunches uvicorn, then waits until an HTTP request to that address gets a response. Any status counts: what the app answers on/is its own business. The wait is bounded (3 min).Startfails. The message carries the process's output tail, so an import error surfaces as a failed Start with its traceback. Before, it was aSTARTEDthat the supervisor revoked a moment later.Startfails.Startfails.Classification: a fix, in the agent that produces
STARTED.STARTEDis the status the CLI orders dependents on (pkg/orchestration/runtime_start_policy.go: "the service started and passed its readiness check"). No core or CLI change.A behaviour change to review: with hot reload on and an app that fails to import, uvicorn's reload supervisor keeps the port bound but serves nothing.
Startnow waits for it to answer, up to the bound. If you fix the source within that time, the reload serves andStartreturnsSTARTED. If not,Startfails and stops the supervisor. Before, such a Start wasSTARTEDimmediately.TestHotReloadParentOutlivesBrokenAppstill pins the supervisor behaviour, because it runs without an Init-resolved address.Test plan
serve_readiness_test.gocovers four cases:STARTEDis withheld until a late listener answers.TestStartReturnsOnceUvicornServesandTestStartFailsWhenUvicornDiesBeforeServingrun against real uvicorn viauv.go test -race -count=1 -skip 'Docker|SBOM|Image' ./passes.gofmtandgo vetare clean.TestCreateToRunDocker*) and the image/SBOM tests. CI runs them.Not verified here
codefly publish dev) throughagent-overrides, and report the result on this PR's parent task, not in this PR.🤖 Generated with Claude Code