Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(relay): a host restarting onto a deleted tunnel gets a new one #16649

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/16649/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

When a desktop quit kills the server after the relay deleted its tunnel but before the server dropped its stored config, the next start registers the deleted tunnel's id. The relay keeps the recorded id after a release, so with an unchanged origin it answered ready without asking Cloudflare, and the host's connector sat at zero connections until someone killed it.

Registration now looks the tunnel up in Cloudflare first. If it is gone, the relay answers recovery_required and the host gets a replacement at the same hostname straight away. This costs one Cloudflare call per server start.

This fixes every client version with one relay deploy. The shorter desktop kill grace that opens the race stays as is: with this change, losing that race heals on the next start, and a longer grace would only make quitting slower when the server hangs.

Tests: a release followed by registration now gets recovery_required, and removing the check fails that test. The two existing registration tests now also expect the lookup.

Built with Claude Opus 5.5 in Claude Code.

🤖 Generated with Claude Code


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Approved at 404eb4a

      Macroscope's review found this PR approvable — This is a focused relay bug fix that validates the recorded Cloudflare tunnel before reporting a host as ready, with tests covering both normal registration and deleted-tunnel recovery. The only existing-path change is one bounded lookup per registration start.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Team
      • Run ID: e7f0a533-bed6-4068-b6e9-72f1cbff7524
      📥 Commits

      Reviewing files that changed from the base of the PR and between 517188b3caa135bc09ec0a4f93474ef17c8b5c4f and 404eb4a536d87a3deb6b8d2daaa09c32299d470e.

      📒 Files selected for processing (2)
      • infra/relay/src/environments/ManagedEndpointProvider.test.ts
      • infra/relay/src/environments/ManagedEndpointProvider.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


      📝 Walkthrough

      Walkthrough

      Origin reconciliation now fetches the recorded tunnel before continuing. Missing or deleted tunnels return "recovery_required", while other lookup errors become provisioning failures at verify-tunnel.

      Changes

      Origin reconciliation

      Layer / File(s)Summary
      Verify the recorded tunnel
      infra/relay/src/environments/ManagedEndpointProvider.ts, infra/relay/src/environments/ManagedEndpointProvider.test.ts
      The provider checks the recorded tunnel before origin reconciliation. Tests cover unchanged origins, deleted tunnels, and port changes.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: t3dotgg

      Merge Risk: ⚪ Minimal · up to 404eb

      No actionable merge-blocking issue is identified; the tunnel verification change is ready for normal merge checks.

      🚥 Pre-merge checks | ✅ 3 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Description check⚠️ WarningThe description explains the problem, the change, and focused test results. It does not include the required Scope and approval information or explain why this focused fix qualifies without prior issu…Add a Scope and approval section. Link the triaged issue or maintainer approval, or explain why this is a small, focused fix for an obvious bug that qualifies without prior discussion.
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly describes the fix: a host restarting with a deleted tunnel receives a new one.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description explains the problem, the change, and focused test results. It does not include the required Scope and approval information or explain why this focused fix qualifies without prior issue or maintainer approval.

      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Comment `@coderabbitai help` to get the list of available commands.
    5. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB−24 B (−0.5%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB−24 B (−2.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB−41 B (−0.2%)29.3 KiB✅
      ClaudeLive turn messages21−1 (−50.0%)8✅

      Baseline: 517188b · PR result: 404eb4a · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    6. juliusmarminge merged thisc4481b9

    7. juliusmarminge closed this

Sign in to join this conversation.