fix(cli): treat run-file removal as stopped in ao stop (#2214)#2215
Open
harshitsinghbhandari wants to merge 1 commit into
Conversation
waitForStopped removed the run-file and then additionally waited for the daemon process to fully exit, erroring with "removed run-file but did not exit within 10s" if it lingered past the stop timeout. The run-file is the daemon's own liveness marker: once it is gone the daemon has committed to stopping. When no desktop client is connected the daemon can drain its background workers slower than the stop timeout, which made ao stop spuriously report failure (the TestE2E_Lifecycle failure in AgentWrapper#2214). Treat run-file removal as stopped: keep polling for full process exit as a best effort (so Windows releases inherited handles before callers clean the data dir) but no longer error when that grace elapses. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Vaibhaav-Tiwari
approved these changes
Jun 26, 2026
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
Fixes #2214.
ao stop->waitForStoppedremoved the daemon's run-file and then additionally waited for the daemon process to fully exit, erroring withdaemon pid <N> removed run-file but did not exit within 10swhen the process lingered past the stop timeout. This is theTestE2E_Lifecyclefailure described in the issue.The run-file is the daemon's own liveness marker. Once the daemon has removed it, the daemon has committed to stopping. When no desktop/supervisor client is connected (as in the e2e harness, and on a user's machine with no running app), the daemon can drain its background workers slower than the 10s stop timeout, so insisting on process-exit made
ao stopspuriously report failure even though shutdown was already underway.Change
In
waitForStopped, when the run-file is gone (info == nil) we now treat the daemon as stopped. We still poll for full process exit as a best effort (so Windows releases inherited handles such asdaemon.logbefore callers clean up the data dir), but exceeding the grace is no longer an error: it returnsstoppedinstead.This is suggested direction #1 from the issue and also fixes the user-facing
ao stopUX on a machine with no connected desktop client.Tests
TestWaitForStoppedReportsStoppedWhenRunFileGoneButProcessLingers: run-file gone + process never exits before deadline -> reportsstopped, no error.waitForStoppedunit tests still pass (concurrent-start guard, own-run-file removal, wait-until-process-exits).go test -tags e2e -run TestE2E_Lifecyclepasses; full./internal/cli/...suite (151 tests) passes;go vetclean.🤖 Generated with Claude Code