fix: auto-restart daemon when CLI binary is rebuilt#41
Conversation
After a rebuild, the daemon keeps running old code. Now ensureDaemon() compares daemon.js mtime against the daemon's startedAt timestamp and restarts automatically if the script is newer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: daf3fcf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51fc92ee4c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (stat.mtimeMs > info.startedAt) { | ||
| // Daemon is stale — restart it | ||
| stopDaemon(); |
There was a problem hiding this comment.
Preserve daemon port when auto-restarting stale process
When the stale-daemon path runs here, ensureDaemon stops the existing daemon but then falls through to startup using only the function argument port; for most CLI commands that call ensureDaemon() (see cli.ts non-start path), this is undefined, so a daemon that was originally started on a custom port is silently restarted on the default 8097. After a rebuild, users on non-default ports will lose their connection target and see unexpected disconnect/no-app behavior. Reuse info.port during auto-restart unless an explicit port override was passed.
Useful? React with 👍 / 👎.
Summary
daemon.jshas been rebuilt since the running daemon started (by comparing file mtime againststartedAttimestamp)stop/startafter every rebuild during developmentTest plan
bun run buildthen run any CLI command — daemon should restart automaticallystatusshows a freshuptimeafter rebuild🤖 Generated with Claude Code