Skip to content

test(daemon): give the spawned helper room to start - #210

Open
ssowonny wants to merge 1 commit into
mainfrom
daemon-test-deadline
Open

test(daemon): give the spawned helper room to start#210
ssowonny wants to merge 1 commit into
mainfrom
daemon-test-deadline

Conversation

@ssowonny

@ssowonny ssowonny commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

TL;DR

  • The macOS CI flake that went red on main and on Desktop parity: the Mac app stops falling behind the web app #209 today, fixed at the cause.
  • TestStopRecoversLegacyDaemon gave a spawned child process 5s to take a file lock — the shortest deadline in the package, on its slowest operation.
  • 30s. A healthy run pays nothing: the loop returns the moment the lock appears.

Why 5s was the wrong number

Every other wait in internal/daemon uses 10s and polls in-process state (secdmnWaitFor, wsWaitFor). This one is the only place that spawns a real child: exec.Command(os.Args[0], "-test.run=TestHelperLegacyDaemon", ...). That child has to boot Go's entire test framework before it reaches the helper and calls syscall.Flock.

So it had the tightest budget for the longest operation. On a loaded GitHub macOS runner it doesn't make it:

--- FAIL: TestStopRecoversLegacyDaemon (5.01s)
    daemon_test.go:177: helper daemon never took the lock

Seen today on main (dd9a5c0) and on #209, same line, macOS only, both green on re-run with no code change. The test dates to #88 (July); nothing in the recent stack touches internal/daemon.

Why the headroom is free

The loop breaks as soon as Running(vdir) reports the lock — the deadline is only a ceiling on how long a genuine failure takes to report, not a delay any passing run waits out. go test ./internal/daemon is 36s here, unchanged.

Deliberately not done: converting this to the package's waitFor helpers. They poll in-process state and this waits on a process; folding them together would hide exactly the difference that caused the flake.

🤖 Generated with Claude Code

TestStopRecoversLegacyDaemon waited 5s for a helper to take the flock — the
shortest deadline in the package for its slowest operation. Every other wait
here is 10s and polls in-process state; this one re-invokes os.Args[0], so a
real child has to boot Go's test framework before it reaches the helper at all.

It duly flaked on a loaded macOS runner, on main and on a PR, at the same line,
both green on re-run with no code change.

30s. The loop returns the moment the lock appears, so a healthy run pays
nothing — the number is only a ceiling on how long a genuine failure takes to
report.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant