Skip to content

[Bug][Windows] Remote Link relay verification times out and leaves a stale Child connection after Home rollback #8947

Open

Description

@ZhenyuXiao

Client or integration

OpenCodex dashboard

Also reproduced through the ocx link add CLI.

Area

Platform (Windows / macOS / Linux)

Windows Remote Link enrollment, relay verification, and failure recovery.

Summary

Adding a Windows Child from a Home can establish the SSH tunnel, persist the Child connection, and synchronize its catalog, but then fail during relay verification because two Windows SSH/PowerShell probes share a 15-second deadline.

The failed enrollment leaves inconsistent state:

  • The Home stops the tunnel and removes its link record, so the device disappears from its dashboard.
  • The Child retains runtimeRole: client and the saved Home/link identity. Its dashboard still says it is managed by that Home.
  • The Child's live connection check reports linkTunnel.state: down with reason: home_unreachable.
  • Retrying Add Child fails because the Child is already configured as a client.

The retry error therefore obscures the initial verification timeout. Expected: sufficient bounded verification time on Windows, and consistent recovery or an explicit recoverable partial-enrollment state on both machines.

Reproduction

Environment: two Windows x64 computers, OpenCodex installed globally through npm, Windows Task Scheduler background services, connected through Tailscale and Windows OpenSSH with existing key-based authentication.

  1. Start with the Child in standalone mode. If reproducing after a failed attempt, first disconnect the specific stale link and verify that the Child has returned to standalone.
  2. From the Home, run:
    ocx link add <child-alias> --expect-fingerprint <verified-fingerprint> --json
  3. Observe the tunnel establish and the Child save its connection/catalog.
  4. On the affected setup, enrollment then fails with child_relay_timeout.
  5. Compare:
    # Home
    ocx link status --json
    
    # Child
    ocx connect status --json
  6. Retry adding the same Child from the Home.

Before the controlled CLI reproduction, the Home diagnostics also contained three attempts that reached tunnel state connected and then stopped approximately 53–60 seconds later. Those events alone do not identify each attempt's original failure. The controlled reproduction captured the precise timeout below.

This is timing-dependent; it is not claimed to reproduce on every Windows installation.

Version

@bitkyc08/opencodex 2.100.5 on both Home and Child.

The original failure was reproduced before applying the local patch described below.

Operating system

  • Home: Microsoft Windows 11 Pro, version 26H2, OS build 26300.9711, x64.
  • Child: Microsoft Windows 11 Pro, version 26H2, OS build 26300.9974, x64.

Both OS editions, display versions, and full build numbers were queried directly on the respective machines. Both OCX services use Windows Task Scheduler.

Provider and model

Not provider-specific: the failure occurs during Remote Link enrollment and catalog relay verification.

Post-fix inference validation used the existing deepseek/deepseek-flash route with a synthetic “Reply with exactly OK.” prompt.

Logs or error output

First captured failure, with the recovery guidance shortened and the link identity redacted:

Error: Remote Link failed during Child relay verification:
ssh command exceeded 4180ms.
The Child may still be connected.
Run ocx disconnect --expect-link <attempt-link-id> on the Child ...
(code child_relay_timeout)
Exit code: 1

Subsequent attempt:

The Child is still linked to a Home (config runtimeRole client).
To end that link and move it here, on the Child run:
ocx disconnect, then ocx restart.

The inconsistent state, reduced to non-sensitive fields:

{
  "home": {
    "role": "standalone",
    "links": []
  },
  "child": {
    "state": "connected",
    "transport": "link",
    "catalog": "present",
    "rotation": "clean",
    "readiness": "ready",
    "linkTunnel": {
      "state": "down",
      "reason": "home_unreachable"
    }
  }
}

The saved state: connected / readiness: ready values did not imply that the live tunnel was up.

Screenshots and supporting files

Source-level findings in the installed 2.100.5 package

  • src/link/remote-probe.ts defines LINK_RELAY_VERIFY_MS = 15_000.
  • In src/server/management/link-enrollment.ts, the post-restart health check and catalog relay verification share one deadline:
    const deadline = now() + LINK_RELAY_VERIFY_MS;
    The remaining time is passed to each successive remote command.
  • Each Windows probe starts a separate SSH/PowerShell command.
  • In the captured failure, only 4180ms remained for the second command. Approximately 10.8 seconds of the shared budget had already been consumed by the preceding check and intervening work.
  • A separate no-business-operation SSH + PowerShell invocation took approximately 3.6 seconds on this setup. This is a local measurement, not a universal Windows baseline.
  • compensateNewLink() in src/server/management/link-route-state.ts revokes the issued key, stops the tunnel, and removes the Home record. After the observed failure, the full OCX Child installation still retained its client configuration.

Additional recovery obstacle: empty desktop-remote directory

Cleaning up the controlled failed enrollment with ocx disconnect --expect-link <attempt-link-id> was refused with desktop_lifecycle_unsafe because %USERPROFILE%\.opencodex\desktop-remote existed but contained neither Claude Desktop remote state nor a disconnect receipt.

Inspection confirmed that this directory was empty and was not a reparse point. Renaming it to a backup location, without deleting it or modifying client configuration, allowed disconnect to complete.

This is an additional recovery obstacle, not asserted to be the cause of the original timeout. It can be split into a separate issue if preferred.

Local workaround and validation

A minimal local patch on the Home changed only the overall Windows relay-verification deadline:

- const deadline = now() + LINK_RELAY_VERIFY_MS, remaining = () => Math.max(1, deadline - now());
+ const deadline = now() + (remotePlatform === "windows" ? 60_000 : LINK_RELAY_VERIFY_MS), remaining = () => Math.max(1, deadline - now());

Each individual HTTP probe remains capped at 15 seconds. Authentication, runtime-role checks, and the complete authenticated catalog-relay verification were preserved.

Observed after the patch and Home service restart:

  • Bun build check of the changed module passed.
  • A fresh Home-initiated enrollment exited 0 and retained the Child in the Home's link list.
  • The Child reported readiness: ready, rotation: clean, and linkTunnel.state: up.
  • The Child's local models endpoint returned HTTP 200 and 23 models.
  • An actual Child → Home → provider request returned HTTP 200, content OK, and finish reason stop.

This supports insufficient shared verification time as the cause of the captured failure. 60 seconds is a locally successful workaround, not a claim that this fixed value is the best upstream design. No full upstream test suite or broader Windows matrix was run.

Requested behavior

  1. Account for Windows SSH/PowerShell startup overhead in the bounded relay-verification budget, so the first probe does not starve the second.
  2. Restore consistent state after failed enrollment where safe. If the Child cannot safely be restored, retain an explicit recoverable record on the Home and provide recovery scoped to the exact attempt/link ID.
  3. Preserve the original failed phase and reason in the dashboard; distinguish saved Home ownership from live connection health.
  4. Provide a safe, actionable recovery path for an empty desktop-remote directory.

Redacted configuration

Relevant state only; this is not a full configuration export:

{
  "beforeEnrollment": {
    "childRuntimeRole": "standalone",
    "childPort": 10100
  },
  "afterFailedEnrollment": {
    "homeLinks": [],
    "childRuntimeRole": "client",
    "transport": "link",
    "linkId": "<attempt-link-id>"
  }
}

Actual hostnames, SSH aliases, addresses, fingerprints, link/key identifiers, account details, and credentials have been omitted or replaced with placeholders.

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. coderabbitai commented on Nov 19, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #8249 - fix(link): report stale Child connection readiness [merged]
    #7560 - fix(link): keep retrying failed Home tunnels, report Child link readiness, record tunnel diagnostics [merged]
    #7832 - feat(link): Windows Remote Link Children and Child credential/connection attestation [merged]
    #8496 - fix(link): show a Child's tunnel state in ocx connect status [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!

  2. added
    bug
    platform
    on Nov 19, 2026
  3. ZhenyuXiao commented on Nov 19, 2026

    @ZhenyuXiao
    Author

    Follow-up: empty desktop-remote directory also blocks normal disconnection

    The empty-directory recovery obstacle described above recurred after successful enrollment. This affects normal Home-initiated disconnection as well as cleanup after failed enrollment.

    Environment: OCX 2.100.5 on both machines; Home Windows 11 Pro 26H2 build 26300.9711 x64, Child Windows 11 Pro 26H2 build 26300.9974 x64, as reported in the issue. The Home had the local relay-verification timeout workaround described above.

    Observed behavior

    1. With the Remote Link established, attempt to disconnect/remove the Child from the Home dashboard.
    2. The dashboard displays a message equivalent to “This computer cannot connect to ” and offers to remove the connection only on this computer, followed by instructions to run ocx disconnect --expect-link <link-id> on the Child.
    3. Read-only checks immediately afterward showed that SSH to the Child worked. ocx connect status --json on the Child still reported the matching link, readiness: ready, and linkTunnel.state: up.
    4. %USERPROFILE%\.opencodex\desktop-remote on the Child existed again as an ordinary, empty directory (zero entries).
    5. The user deleted that empty directory and confirmed that disconnection then succeeded.

    The installed source's desktopLifecycleRefusal() maps root_without_state to a refusal ending in desktop_lifecycle_unsafe: the directory exists but contains neither Claude Desktop remote state nor a disconnect receipt. The earlier cleanup attempt in this issue captured that refusal directly. For this later dashboard attempt, we did not capture the complete backend error response or rerun the failing disconnect during diagnosis; the successful workaround above is user-confirmed.

    Expected behavior

    • Handle an ordinary, verifiably empty desktop-remote directory safely, or provide an explicit, actionable recovery message identifying that directory. Preserve safeguards for nonempty, unreadable, or otherwise ambiguous state.
    • Surface the actual remote disconnect refusal in the dashboard instead of presenting it as an inability to connect to the Child. Working SSH and an active relay do not imply that application-level cleanup will succeed.
    • Investigate why the empty directory reappears after it has been moved aside and enrollment/synchronization has run. The exact operation recreating it has not yet been isolated.

    Please treat this as additional evidence for the recovery obstacle already included in this issue, or split it into a separate defect if preferred. Hostnames, connection identifiers, and credentials are omitted.

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

    bugplatform

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions