Add a server-side home-relay watchdog with in-process endpoint rebuild - #92
Merged
Merged
Conversation
A custom-relay server is dialable from off the LAN only while it is registered on its home relay. iroh 1.0.3 has been observed to silently lose that registration for good after a routine relay reconnect (relays behind Cloudflare tunnels reset idle WebSockets roughly hourly): no dial retries, no warnings, no registration on either relay. Relay-only clients — the iOS app, anything off the LAN — then time out until the service is restarted, while LAN clients that find the server over mDNS keep working and hide the outage. The watchdog observes the endpoint's home-relay status and escalates like the client's reconnect loop: after 60s without a connected home relay it nudges the endpoint with `network_change()`; if there is still none at 180s the serve loop closes the endpoint, binds a fresh one with the same identity and allowlists, and serves on. Armed for custom relays only. Bridge tasks are now owned by the run they belong to so a rebuild never leaves them retrying on a closed endpoint. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C8wQiBCRQvGWxPKFu435YP
The rebuild retry wait only polled the retry timer and the shutdown signal, so a `server start --quick` whose rebuild kept failing would outlive its 5-minute grace. Poll the pinned grace future there too; nothing is bound during that wait, so it returns without an endpoint close. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C8wQiBCRQvGWxPKFu435YP
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C8wQiBCRQvGWxPKFu435YP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
transport::relay_watchdogwatchesEndpoint::home_relay_status(): after 60s without a connected home relay it nudges withnetwork_change(); still none at 180s and the serve loop closes the endpoint, binds a fresh one with the same identity/allowlists (server_rebuild_factory), and serves on. Armed for custom relays only.runthey belong to (aJoinSet), so a rebuild never leaves them retrying on a closed endpoint;BridgeUpstream::runclears a stale connection slot on start.Test plan
ci/unix/ci.shon Linux: clippy-D warnings+ tests pass (5 new watchdog unit tests under paused tokio time)🤖 Generated with Claude Code
https://claude.ai/code/session_01C8wQiBCRQvGWxPKFu435YP