Skip to content

fix: stop orphaned mock on healthcheck timeout#129

Open
outofcoffee wants to merge 1 commit into
mainfrom
claude/beautiful-volta-b9rl6
Open

fix: stop orphaned mock on healthcheck timeout#129
outofcoffee wants to merge 1 commit into
mainfrom
claude/beautiful-volta-b9rl6

Conversation

@outofcoffee
Copy link
Copy Markdown
Contributor

@outofcoffee outofcoffee commented May 27, 2026

Stop the just-started mock when the engine fails to become healthy within the start timeout, so a failed imposter up no longer leaks a process or container.

Summary

  • WaitForOp / WaitForUrl / WaitUntilUp no longer call logger.Fatalf on timeout; they now return an extra timedOut bool so callers can distinguish a healthcheck timeout from an external abort and clean up accordingly.
  • The JVM, native, and Docker engines stop the mock they just started when the healthcheck times out (including in the --detach=healthy path).
  • cmd/up.go records whether Ctrl+C fired before cleanup, then exits non-zero on a genuine failed start while still returning cleanly on an interrupt.
  • Added internal/engine/health_test.go covering the three WaitForOp outcomes (success, timeout-without-exit, abort).

Closes #123

Implementation details

The interrupted flag in trapExit is set before StopImmediately runs, so by the time Start returns and the main thread reads the flag, it reliably reflects whether the false return came from a signal or from a timeout. This avoids double-stopping in the abort case (where StopImmediately already kills the mock) while still cleaning up in the timeout case (where the engine itself calls Stop).

On a healthcheck timeout, WaitForOp called logger.Fatalf, terminating the
CLI via os.Exit before engine shutdown ran. This left the just-started
mock orphaned: process engines reparented their child to init, and the
docker engine left its container running in dockerd.

WaitForOp now reports a timeout (returning false plus a timedOut flag)
instead of exiting. Each engine stops the mock it started when the
healthcheck times out, and `up` exits non-zero only for genuine failures,
distinguishing a timeout from a Ctrl+C abort via the interrupt flag.

https://claude.ai/code/session_01V2yVKgX16c7eLrTXtSVQs4
@outofcoffee outofcoffee changed the title Distinguish healthcheck timeout from abort in startup flow fix: stop orphaned mock on healthcheck timeout May 27, 2026
@outofcoffee outofcoffee added bug Something isn't working go labels May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: healthcheck timeout leaves orphaned mock process/container

2 participants