Skip to content

fix(daemon): stop dev-mode restarts from 0.0.0.0 connect + watchMeta retry spin#1179

Open
vibegui wants to merge 1 commit into
mainfrom
vibegui/dev-restart-fix
Open

fix(daemon): stop dev-mode restarts from 0.0.0.0 connect + watchMeta retry spin#1179
vibegui wants to merge 1 commit into
mainfrom
vibegui/dev-restart-fix

Conversation

@vibegui

@vibegui vibegui commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Lead reported that the dev experience for deco sites has degraded over the last few weeks with intermittent restarts. After investigating I found two issues that compound to produce that symptom:

  • daemon/workers/denoRun.ts:85 — PR Revert "fix(daemon): remove Deno HTTP proxy client from worker fetch" #1173 (Apr 17) wholesale-reverted fix(daemon): remove Deno HTTP proxy client from worker fetch #1170, which silently brought back `0.0.0.0` as the worker connect hostname. `0.0.0.0` is a bind wildcard, not a valid outbound connect target on macOS/Linux — connections through it are platform/Deno-version-dependent and flake. This PR restores only the hostname half of fix(daemon): remove Deno HTTP proxy client from worker fetch #1170 (`127.0.0.1`) and leaves the proxy-client decision alone, since that was reverted for a separate legitimate Vite asset-routing reason.
  • daemon/meta.ts — `watchMeta`'s long-poll loop has a catch path that just logs and continues, with no backoff. When the worker fetch fails fast (connection refused mid-restart, the hostname flake above, etc.) it becomes a tight CPU-pegging spin that floods stderr until a process supervisor kills the daemon — i.e. the "restarts". This PR adds a 1s backoff, matching the pattern already used on the 304 path.
  • daemon/main.ts — added a one-line startup log of `UNSTABLE_WORKER_RESPAWN_INTERVAL_MS` so scheduled restarts (`Deno.exit(1)` on a timer) can be ruled in/out at a glance.

15 lines changed across 3 files.

Test plan

  • `deno check daemon/main.ts daemon/workers/denoRun.ts daemon/meta.ts` passes
  • Run dev mode on macOS against a real deco site and confirm the worker-fetch errors disappear from logs and the site responds without intermittent failures
  • `kill -9` the child Deno worker mid-session and confirm the daemon recovers without a tight spin (≤1 error/sec in stderr until the worker comes back, not thousands)
  • Confirm the new startup log shows the respawn-interval value (or "unset")

🤖 Generated with Claude Code


Summary by cubic

Stops intermittent dev-mode restarts by connecting workers to 127.0.0.1 (not 0.0.0.0) and adding a 1s backoff to prevent tight retry spins. Also logs UNSTABLE_WORKER_RESPAWN_INTERVAL_MS at startup for quick diagnosis.

  • Bug Fixes

    • Use 127.0.0.1 for worker outbound connections on non-Windows (0.0.0.0 -> 127.0.0.1).
    • Add 1s backoff in watchMeta error path to avoid CPU spin and stderr flood during worker restarts.
  • New Features

    • Log UNSTABLE_WORKER_RESPAWN_INTERVAL_MS on daemon startup to help rule out scheduled restarts.

Written for commit 383efee. Summary will update on new commits. Review in cubic

Summary by CodeRabbit

  • New Features

    • Added startup logging to display the configured worker respawn interval setting for better visibility.
  • Bug Fixes

    • Fixed proxy configuration for non-Windows systems to use the correct loopback address.
    • Improved retry behavior with throttling to reduce CPU usage and excessive logging during failures.

The Apr 17 revert of #1170 (#1173) bundled together two unrelated
changes and re-broke the worker connect hostname. Restore only the
surgically-isolated hostname half (0.0.0.0 -> 127.0.0.1) and leave
the proxy-client decision alone.

Also:
- Add a 1s backoff to watchMeta's catch path. Without it, a fast-
  failing worker fetch (connection refused mid-restart, etc.) tight-
  loops the long-poll, pegging CPU and flooding stderr until a
  supervisor kills the daemon.
- Log UNSTABLE_WORKER_RESPAWN_INTERVAL_MS at startup so scheduled
  restarts can be ruled in/out at a glance.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 1.196.7 update
  • 🎉 for Minor 1.197.0 update
  • 🚀 for Major 2.0.0 update

@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2280d725-ea3e-4f4b-a769-f2f2ec7bd6fe

📥 Commits

Reviewing files that changed from the base of the PR and between f168d3c and 383efee.

📒 Files selected for processing (3)
  • daemon/main.ts
  • daemon/meta.ts
  • daemon/workers/denoRun.ts

📝 Walkthrough

Walkthrough

Three targeted improvements: adds runtime logging for worker respawn interval configuration visibility, implements error backoff throttling in metadata watching retry loop to reduce CPU and stderr usage, and corrects proxy connect address from bind-wildcard to loopback on non-Windows systems.

Changes

Cohort / File(s) Summary
Startup Configuration Logging
daemon/main.ts
Adds console.log output at startup to display the UNSTABLE_WORKER_RESPAWN_INTERVAL_MS environment variable value (or "unset") for runtime visibility.
Polling Retry Backoff
daemon/meta.ts
Introduces 1-second backoff delay after logging non-408/404 errors in watchMeta retry loop, preventing immediate polling re-entry and reducing CPU/stderr overhead.
Proxy Address Correction
daemon/workers/denoRun.ts
Changes non-Windows proxy hostname from wildcard bind address (0.0.0.0) to loopback address (127.0.0.1), with clarifying comments on address semantics across operating systems.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • guitavano
  • hugo-ccabral

Poem

🐰 A rabbit hops through daemon code,
Three tweaks along the bumpy road:
Log the intervals, slow the retries,
Fix the loopback—no more tries!
Small fixes make the service spry. 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the two main fixes: resolving 0.0.0.0 connection issues and preventing watchMeta retry spin, which align with the core changes across all three files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch vibegui/dev-restart-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

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