hub: keep reconnecting trusted devices that briefly leave mDNS#89
Closed
andig wants to merge 3 commits into
Closed
hub: keep reconnecting trusted devices that briefly leave mDNS#89andig wants to merge 3 commits into
andig wants to merge 3 commits into
Conversation
cleanupRemovedMdnsEntries cancels the connection delay timer and attempt counter for any SKI missing from the latest mDNS snapshot. For an untrusted device that genuinely left the network this is the intended resource saving, but for a trusted/paired device it strands a pending reconnect: the scheduled dial is cancelled and only re-initiated once the device happens to re-announce. This regularly happens right after the remote restarts - it stops announcing for a moment while the local hub, having re-registered the persisted trust via RegisterRemoteService, has already scheduled a dial. A single missing snapshot then cancels that dial and the device stays disconnected until the next announcement. Skip the cleanup for trusted SKIs so their pending reconnect survives a transient mDNS drop; untrusted discovery attempts are still cleaned up.
Contributor
Author
|
Test flake seems unrelated but I can't restart it. |
kirollosnct
self-requested a review
July 12, 2026 11:26
sthelen-enqs
self-requested a review
July 24, 2026 13:31
Contributor
|
I think we'll need to discuss in the team if and how we want to handle this. |
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.
Fixes #88.
cleanupRemovedMdnsEntriescancels the pending connection dial (delay timer + attempt counter) for every SKI missing from the latest mDNS snapshot. That is the intended resource saving for untrusted discovery (introduced in67a274b), but it also strands trusted/paired devices: when a trusted remote briefly stops announcing (e.g. during a restart) after the hub has already scheduled a dial, the next snapshot omits its SKI, the dial is cancelled, and the reconnect is not re-initiated until the device happens to re-announce.Skip the cleanup for SKIs where
IsRemoteServiceForSKIPairedis true, so a trusted device keeps retrying across a transient mDNS drop. Untrusted discovery attempts are still cleaned up as before.Test
Added
TestReportMdnsEntries_TrustedServiceSurvivesTransientMdnsDrop: a trusted service with a scheduled reconnect, then an mDNS report that omits its SKI; the pending dial must survive.Without the fix (test applied to unchanged
hub_mdns.go) it fails, showing the dial being cancelled:With the fix it passes, and the full
hubpackage is green.Context
Found via a flaky EEBus reconnect-after-restart in evcc (evcc-io/evcc#31534, evcc-io/evcc#31570), whose logs show the cancellation for a paired controlbox:
This change removes that cause and substantially reduces the downstream flake, but does not fully eliminate it: a separate race, where a trusted device's re-announcement after restart is rejected as a replay and its trust is transiently not set when the cleanup runs, can still cancel the reconnect. That is out of scope here and worth tracking separately.
🤖 Generated with Claude Code