[Bug] nanocoder daemon start reports failure (exit 1) when the daemon takes more than 5s to boot, though it comes up
Description
nanocoder daemon start waits a fixed 5 seconds for the daemon's lockfile (source/daemon/cli.ts:182). If the daemon needs longer (a large repo, a cold start, a busy disk), start prints a failure and exits with code 1, but the daemon keeps booting and is running a few seconds later. Scripts and service managers treat the exit code as a failure. A retry made before the lockfile exists starts a second daemon that fails with "Daemon already running".
Environment
- OS: Windows 11 (10.0.26300)
- Node version: 22.22.3
- Nanocoder version: 1.31.0 (main at 9d88dda7)
- Provider / Model: not relevant
Steps to Reproduce
- In a trusted git project, run
nanocoder daemon starton a machine or repo where the daemon takes longer than 5 seconds to start. To simulate this, run it withNODE_OPTIONS="--require slow-boot.cjs", whereslow-boot.cjswaits 8 seconds only when the process isdaemon/entry. - Run
nanocoder daemon statusright away, then again 14 seconds later. - Run
nanocoder daemon startagain before the daemon has written its lockfile. - Read
.nanocoder/daemon.log.
Expected Behavior
start reports that the daemon is still starting (and exits 0), or waits long enough. A second start during boot does not launch another process.
Actual Behavior
Daemon process spawned but did not write a lockfile within 5s. Check the daemon log. (exit 1)
status right after : Not running.
retry start : Daemon process spawned but did not write a lockfile within 5s. ...
status 14s later : Running. pid 26460, ..., uptime 14s.
daemon.log: Daemon started for <project> (pid 26460).
Daemon failed to start: Error: Daemon already running for <project> ...
The first, unslowed run on a cold machine also failed this way once and showed Running ... uptime 0s a moment later. With warm starts it took 4-5 seconds, right at the limit.
Suggested Fix
source/daemon/cli.ts:182-189: use a longer or configurable timeout. On timeout, if the child process is still alive, reportDaemon is still starting (pid N). Run "nanocoder daemon status" to check.and exit 0 instead of failing.- Optional: write a "starting" lockfile as soon as the process begins, so a second
startsees it. - Add a test that fakes a slow boot and checks the exit code.
Additional Context
- Daemon CLI came from #1457. Open PR #1733 only changes
stop. - [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs with the latest version of nanocoder
Hi, I’d like to work on this. I’ll investigate the daemon startup timeout behavior, implement a safe status/timeout handling path, and add regression coverage for slow boot. Could you please assign it to me?
hey @addyCooks i would like to work on this can you assign me this issue