Skip to content

Daemon doesn't retry machine registration after DNS failure at startup #129

@lucharo

Description

@lucharo

Summary

When the Happier daemon starts before DNS is available (e.g., at system boot), machine registration fails with EAI_AGAIN and the daemon continues running without ever retrying registration. This means the machine is invisible to the server and remote session creation from the phone doesn't work — until the daemon is manually restarted.

Steps to Reproduce

  1. Have happier daemon start run at system boot (e.g., via systemd or as part of shell profile)
  2. If the daemon process starts before the network/DNS is fully ready, registration fails:
    [WARN] [DAEMON RUN] Machine registration unavailable at startup; continuing without machine sync until next restart
    {"name":"Error","message":"getaddrinfo EAI_AGAIN api.happier.dev","code":"EAI_AGAIN","method":"POST","url":"https://api.happier.dev/v1/machines"}
    
  3. The daemon keeps running and works for locally-started sessions (file watcher, session scanner all work fine)
  4. But the phone/app can't see the machine or start new sessions on it

Expected Behavior

The daemon should retry machine registration with exponential backoff when the initial attempt fails, rather than giving up permanently.

Workaround

Manually restart the daemon after the network is up:

happier daemon stop && happier daemon start

Environment

  • OS: Arch Linux (headless server, starts with lid closed)
  • Happier CLI: 0.1.0
  • Node: v25.6.1

Suggested Fix

Add a retry loop with exponential backoff to the machine registration step in the daemon startup flow. Something like: retry 5 times with 5s/10s/30s/60s/120s delays before giving up.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions