Skip to content

[Bug]: Remote Link Child on a sleeping laptop reports connected/ready while the Home tunnel is failed, and recovery after wake waits up to 5 min #8470

Closed

Description

@lidge-jun

Summary

A Home-initiated Remote Link to a macOS laptop Child drops every time the laptop sleeps, as designed. Two things then go wrong:

  1. The Child's own status lies. While the Home showed the link failed (reason: timeout), the Child's ocx connect status kept reporting Connection: connected, readiness: ready, and Key rotation: clean. Every real request from Codex on that Child failed with 503 home_unreachable ("link tunnel unavailable"). Someone checking only the Child sees a healthy link and cannot tell why Codex is failing.
  2. Recovery after wake is slow and looks like an outage. After the laptop woke, the link stayed failed for minutes. The next scheduled retry was up to 5 minutes away under HOME_TUNNEL_RETRY_POLICY (60 → 120 → 240 → 300 s cap). A manual ocx link reconnect on the Home connected in 6 s, which confirms the network had been fine for a while.

Environment

  • Home: macOS, opencodex 2.100.0
  • Child: macOS 15.7.3 laptop on battery, joined via ocx link add (Home-initiated, -R tunnel), with Codex and Claude selected
  • Transport: Tailscale (shared device) + regular macOS sshd

Evidence (2026-11-10, KST)

Each tunnel drop in the Home's ~/.opencodex/link/diagnostics.jsonl matches a sleep entry in the Child's pmset -g log:

Child pmset Home tunnel transition
00:46:07 Idle Sleep 00:46:41 connected → reconnecting (network); 00:51:42 → failed (timeout)
12:55:51 Wake (lid) 13:01:11 failed → connected (+5m20s)
13:56:56 Idle Sleep 13:57:56 connected → reconnecting; 14:02:56 → failed (timeout)
14:52:28 Wake (lid) 14:56:03 failed → connected (+3m35s)
15:53:04 Clamshell Sleep 15:54:03 connected → reconnecting; 15:59:03 → failed (timeout)
16:26:34 Wake (lid) 16:27:16 retry still failed (network); next retry was due 16:32:16. Manual ocx link reconnect at 16:31:04 → connected at 16:31:10

While the link was failed (checked 16:30):

  • From the Home, Tailscale ping and three plain ssh <child> 'echo ok' calls to the Child all succeeded.
  • Child ocx connect status: Connection: connected, Transport: link, Key rotation: clean, catalog present
  • Child GET 127.0.0.1:10100/v1/models → 0 models
  • Child POST 127.0.0.1:10100/v1/responses → 503 {"code":"home_unreachable","error":"link tunnel unavailable", ...}

After the manual reconnect, the same requests returned 30 models and a normal gpt-6.1-sol completion.

Expected

  • ocx connect status / readiness on a link Child reflects tunnel liveness. If the reverse-tunnel port has no listener, or the last relayed request failed with home_unreachable, it should not report connected / ready. The request path already detects this.
  • A Child coming back from sleep heals in seconds, not up to five minutes.

Suggestions

  • Child status: probe the tunnel port (or reuse the relay's last home_unreachable result) and report something like connected (tunnel down since …) or degraded, so readiness is no longer static.
  • Faster wake recovery on the Home: while a link is failed under the 300 s cap, run a cheap reachability probe more often (e.g. TCP connect to the Child's sshd every 15–30 s, or a Tailscale peer-online signal). When it succeeds, reset the backoff and spawn right away. This keeps the "≤12 sshd attempts per hour" property for genuinely dead hosts.
  • Diagnostics: the failed retries were all labelled network and carried no stderr. Overlaps [Feature]: Add durable Remote Link failure diagnostics and opt-in tunnel debug logging #7297.

Context: the drop itself is expected (the policy comment in src/link/tunnel-state.ts calls out sleep explicitly). This issue is about the misleading Child status and the slow, invisible recovery afterwards.

Activity

  1. added
    bug
    cli
    on Nov 10, 2026
  2. coderabbitai commented on Nov 10, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #7560 - fix(link): keep retrying failed Home tunnels, report Child link readiness, record tunnel diagnostics [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  3. lidge-jun commented on Nov 10, 2026

    @lidge-jun
    OwnerAuthor

    The Child-side status half is in #8496: ocx connect status on a link Child now prints Link tunnel: up | down (<reason>) | unknown (<reason>) from the running Child's /readyz verdict, and --json carries it as linkTunnel.

    The other half, how fast the Home reconnects after a sleeping Child wakes, is a retry-policy choice, so I am leaving it for the owner instead of changing it here. Today HOME_TUNNEL_RETRY_POLICY (src/link/tunnel-state.ts) reuses the client policy: timeout and forward failures retry after 60 s, doubling to a 300 s cap, and auth starts at 300 s, which limits a dead host to 12 sshd attempts an hour.

    Options:

    1. Keep 60→300 s. Wake recovery stays slow (up to 5 min), with no new traffic.
    2. Cheap reachability probe while failed: TCP-connect to the Child's sshd every 15–30 s and, on success, reset the backoff and spawn. Recovery takes seconds. Each probe is an unauthenticated sshd connection that shows up as a preauth disconnect in the Child's sshd log, and fail2ban-style rules in aggressive mode can count it.
    3. Cap only timeout/forward retries at 60 s for Home tunnels, keeping auth at 300 s. A sleeping host never reaches sshd, so these retries add no authentication attempts. Recovery is at most about 60 s after wake.

    Recommendation: 3. It is one policy constant and keeps the auth bound that the 12-per-hour comment protects. This issue stays open for that decision.

  4. lidge-jun commented on Nov 10, 2026

    @lidge-jun
    OwnerAuthor

    The Child status half landed in #8496 (15cf4c9018). ocx connect status on a link Child now prints Link tunnel: up | down (<reason>) | unknown (<reason>), and --json carries it as linkTunnel. The issue stays open for the wake-recovery cadence decision in the comment above.

  5. lidge-jun commented on Nov 10, 2026

    @lidge-jun
    OwnerAuthor

    Decision (coordinator, 11-11): cap only the Home tunnel's timeout/forward retries at 60 s, so a Child that wakes reconnects within about a minute. The auth retry and the hourly bound on login attempts stay as they are. Implementation follows in a PR for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcli

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions