fix(core): actually re-advertise on discovery visibility resume - #143
Merged
Merged
Conversation
pauseAllAdvertisements/pauseAdvertisementsForBackend discarded the real AdvertiseOptions a caller passed to advertise(), replacing them with an inert placeholder. resumeAllAdvertisements/resumeAdvertisementsForBackend then only deleted the paused bookkeeping entry and never called backend.startAdvertising again, so toggling mesh visibility from quiet/dark back to discoverable silently left the mesh unadvertised on every backend, with getVisibility() reporting "discoverable" the whole time. DiscoveryManager now keeps the real opts alongside each active and paused advertisement, and resume genuinely calls backend.startAdvertising(opts) again. The caller-visible advertisement id is now minted by DiscoveryManager itself (via nanoid, distinct from whatever id a backend returns internally) and kept stable across a pause/resume cycle, so a caller holding an id from before a visibility change can still address the same logical advertisement afterwards -- a backend is free to return a different internal id on every startAdvertising call, and DiscoveryManager no longer depends on backend id determinism to keep working correctly.
Mearman
marked this pull request as ready for review
September 16, 2026 05:00
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🎉 This PR is included in version 2.31.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Part of #51's own named bug ("fix the live pauseAllAdvertisements/resumeAllAdvertisements bug found in passing").
DiscoveryManager.pauseAllAdvertisements/pauseAdvertisementsForBackenddiscarded the realAdvertiseOptionsa caller passed toadvertise(), replacing them with an inert{name: "resumed", port: 0}placeholder.resumeAllAdvertisements/resumeAdvertisementsForBackendthen only deleted the paused bookkeeping entry and never calledbackend.startAdvertisingagain -- so toggling mesh visibility fromquiet/darkback todiscoverablesilently left the mesh unadvertised on every backend, whilegetVisibility()kept reporting"discoverable"the whole time. No test exercised this path at all before this PR (visibility.integration.test.tsonly ever checkedgetVisibility()'s own state transitions, never that pausing/resuming actually drove a backend).DiscoveryManagernow keeps the real opts alongside each active and paused advertisement, and resume genuinely callsbackend.startAdvertising(opts)again. Along the way, fixed a second, related gap the naive fix would have introduced: the caller-visible advertisement id is now minted byDiscoveryManageritself (viananoid, distinct from whatever id a backend returns internally) and kept stable across a pause/resume cycle -- a caller holding an id from before a visibility change (e.g. to later callmesh_unadvertise) can still address the same logical advertisement afterwards, rather than the id silently changing underneath it.DiscoveryManagerno longer relies on a backend's own id-generation being deterministic (the real mdns/tailscale backends happen to be, but nothing enforced that as a contract).Test plan
pnpm typecheckpnpm lintpnpm test(798/798)pnpm build