Skip to content

Bound mobile reconnects and slow retries to offline Tailscale hosts - #47217

Merged
nwparker merged 7 commits into
mainfrom
nwparker/Network-fix
Nov 23, 2026
Merged

nwparker merged 7 commits into
mainfrom
nwparker/Network-fix

Conversation

@nwparker

@nwparker nwparker commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca Mobile gives a newly available network a short chance to recover while slowing passive retries to saved Tailscale hosts that keep failing.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​33
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​147 $\color{#cf222e}{\Huge{\mathbf{−}}}$​47 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​100

What Changed

  • A network callback burst gets one immediate retry and a bounded follow-up. A quickly refused first retry can try once more after at most two seconds. A follow-up lets a new dial run for at least four seconds before replacing it. Repeated callbacks during the same burst leave the active retry schedule in place.
  • Focus and older downloaded pages' Retry can advance a scheduled retry and leave an in-flight dial alone. Accelerated dials preserve the numeric backoff step. App resume retains its normal fresh retry budget for a previously reachable host.
  • A saved Tailscale host that has never authenticated this session moves to five-minute automatic retries after exhausting the standard attempts. Passive network hints respect a two-minute minimum between dials. Returning from the background has a separate retry budget, so a recent timer dial cannot consume it. An explicit focus or Retry can still dial immediately. The dormant timer skips dialing outside the foreground.

Why

The iOS VPN can report a restored path before traffic can use it. Resetting backoff on each passive callback creates repeated connections to an unreachable host. Holding back every later callback can leave a recovered host stuck on a long retry timer.

Traffic to an offline peer also triggers a WireGuard buffer-pool stall in Tailscale's stable iOS 1.104.7 configuration. I reproduced it with that release's actual wireguard-go module and iOS queue options in the upstream loopback test. The healthy peer first timed out when the pool filled at 1 minute 37 seconds. Traffic resumed at 3 minutes 17 seconds when the queue drained. The fixed TestFlight module kept the healthy peer reachable for the same four-minute workload. This points to keeping needless offline traffic quiet and preserving a prompt recovery path.

Linked Issue

Refs #31580, #19111, #46828, and #13354. Incorporates the dormant-host approach from @luben93's #36352, which overlaps this PR and has conflicts with current main. The physical iPhone failure from #31580 still needs a capture. Tailscale upstream issue

Validation

Claude Opus and Gemini 4 Neon independently reviewed the previous revisions. The current policy addresses their repeatable recovery and retry-pressure findings. I replayed the worker's controlled socket scenarios using the production direct client.

Scenario Earlier revision Current implementation
Tunnel becomes reachable one second after a lone network hint 60 seconds 2 seconds
Two early hints during a healthy three-second handshake 5.5 seconds, two dials 3 seconds, one dial
Toggle and return after launching during an outage 60.5 seconds in the dormancy prototype Immediate when eligible
Toggle and return after a recent failed dormant dial 252 seconds Immediate on the first app return
Tailscale toggle after a long outage with a previously connected host 90 seconds on the earlier sliding-window version 2 seconds
Unreachable host with a five-second callback cadence over two minutes 96 dials on main 4 dials

The replay also verified older-page Retry, app-resume request budgets, focus storms, ten-second callback cadence, and an independent healthy host while a second host was offline. All 21 replay cases, five existing delivery-ambiguity tests, and the new dormant app-return regression test passed. All 17 local changed checks passed.

The simulation uses controlled socket events. Physical verification and tap-by-tap timing on the reporter's iPhone are pending.

Performance

At most one network follow-up timer per direct client during a burst. Authentication, close, and terminal authentication failure cancel it. Automatic retries to an exhausted offline Tailscale host are less frequent.

Risk

Level: Medium. Continuous network hints can use up the burst's expedited retries while a path is still unavailable. The regular schedule and user-driven Retry remain available, and dormant automatic retries have an explicit interval. The bridge and wire types are unchanged. A plain revert restores the previous retry behavior.

Agent skill upstream boundary

  • No upstream agent skill source or artifacts were copied.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

RpcClientReconnectSchedule handles network-change hints with an immediate retry on the first hint or after a 10-second interval. It allows one delayed follow-up retry after closely spaced hints. Authentication clears hint state, and cancel() clears both reconnect and follow-up timers. DirectRpcClient.notifyForeground routes network-change notifications through this policy and handles other reasons directly. It closes stale dials only for non-focus notifications.

Merge Risk: Moderate · up to 7353d

Tapping Retry on the offline banner after a long outage now dials once and then waits up to 90 seconds before the next attempt, instead of resuming normal backoff. Restore the attempt reset for focus-triggered retries from scheduled backoff before merging.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description follows the template and covers most required sections: ELI5, What Changed, Why, Validation (testing evidence), Performance, Risk with a Level, and the Agent skill upstream boundary ch… 1. In Linked Issue, replace the 'Refs' lines with an actual closing reference such as 'Fixes #' for an issue this PR resolves, or state that the author is a maintainer and attach the existing issue. 2. In Visual Proof, add a BEFORE a…
Passed Passed checks: 3 passed

Check name Status Explanation
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.
Title check Passed The title names the main change: reconnect and retry behavior for Orca Mobile direct connections is bounded when saved Tailscale hosts are offline. The changeset adds network-hint retry handling in th…
Full details: Title check

Explanation

The title names the main change: reconnect and retry behavior for Orca Mobile direct connections is bounded when saved Tailscale hosts are offline. The changeset adds network-hint retry handling in the reconnect schedule and slows automatic retries to exhausted offline Tailscale hosts, so the title matches the primary intent. It is 67 characters, which is within a reasonable title length.

Full details: Description check

Explanation

The description follows the template and covers most required sections: ELI5, What Changed, Why, Validation (testing evidence), Performance, Risk with a Level, and the Agent skill upstream boundary checkbox. Gaps: the Linked Issue section does not contain a 'Fixes #' issue link. It lists 'Refs' to several issues, which the template says is not sufficient for outside contributors. The Visual Proof section is missing: the change affects mobile reconnect behavior, so it needs either a before/after capture or an explicit 'N/A' with a reason. The description also says physical iPhone verification is pending. The Testing section does not use the template's checklist (the manual test, automated test, and anti-pattern boxes are not marked). The AI Disclosure section is absent, though it is only needed for non-team contributors. The Performance section gives a one-line answer, which is acceptable. The description is mostly complete, but the missing Linked Issue closure and Visual Proof make it incomplete.

Resolution

  1. In Linked Issue, replace the 'Refs' lines with an actual closing reference such as 'Fixes #<issue>' for an issue this PR resolves, or state that the author is a maintainer and attach the existing issue. 2. In Visual Proof, add a BEFORE and AFTER capture (video preferred) of the reconnect behavior, or write 'N/A' with a reason. Note that the physical iPhone capture is still pending. 3. In Testing, mark the checklist items that apply, and state which platforms were tested (the physical iOS test is pending, so say so). 4. If the author is an outside contributor, complete the AI Disclosure section if AI tools were used for the code or the review.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@nwparker
nwparker force-pushed the nwparker/Network-fix branch from bee93a8 to a9c904e Compare November 23, 2026 00:29
@nwparker
nwparker marked this pull request as draft November 23, 2026 00:40
@nwparker
nwparker force-pushed the nwparker/Network-fix branch from a9c904e to f9b3db6 Compare November 23, 2026 00:44
@nwparker
nwparker marked this pull request as ready for review November 23, 2026 00:45
@nwparker
nwparker marked this pull request as draft November 23, 2026 00:52
Use the dormant retry approach from #36352 for cold Tailnet endpoints, while keeping a direct retry available when the user opens the host. Coalesce repeated native callbacks over the cadence observed on iOS.

Co-authored-by: lucas persson <[email protected]>

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7565179f-11b1-4aa4-90a0-2ec8a23c2512
Commits

Reviewing files that changed from the base of the PR and between f9b3db6 and 7353db4.

Files selected for processing: 2

  • mobile/src/transport/rpc/direct-rpc-client.ts
  • mobile/src/transport/rpc/rpc-client-reconnect-schedule.ts

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

hadTimer: this.reconnect.hasTimer()
})
this.reconnect.redialNow(!abandoned)
this.reconnect.redialNow(reason === 'app-resume' && state === 'reconnecting')

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.

Major · Functional Correctness · Quick win

Restore the attempt reset when focus starts from scheduled backoff.

Line 210 passes false to redialNow for every focus call. A focus call from reconnecting does not reach the stale-dial branch, so the merge-base code reset attempts for this input. The current code keeps the attempt count. The offline banner's Retry action uses focus, so a Retry at attempt 12 dials once. If that dial fails, the client waits the 90-second trickle delay instead of the normal backoff.

Reset attempts for focus. Keep them unchanged for network-change, which the PR intends to exclude from resetting the counter. Stale-dial replacement already captures connecting or handshaking, so it keeps its current behavior.

Suggested fix

--- "a/mobile/src/transport/rpc/direct-rpc-client.ts"
+++ "b/mobile/src/transport/rpc/direct-rpc-client.ts"
@@ -207,7 +207,7 @@
       this.socketClose.forceClose(dialing)
     }
     if (this.getState() === 'reconnecting') {
-      this.reconnect.redialNow(reason === 'app-resume' && state === 'reconnecting')
+      this.reconnect.redialNow(state === 'reconnecting' && reason !== 'network-change')
     }
   }
 
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
this.reconnect.redialNow(reason === 'app-resume' && state === 'reconnecting')
this.reconnect.redialNow(state === 'reconnecting' && reason !== 'network-change')

@nwparker nwparker changed the title Keep Orca Mobile direct reconnects on backoff during repeated network hints Bound mobile reconnects and slow retries to offline Tailscale hosts Nov 23, 2026
@nwparker
nwparker marked this pull request as ready for review November 23, 2026 01:00
@nwparker
nwparker merged commit 7c50df0 into main Nov 23, 2026
25 of 26 checks passed
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