/
/
/
# What does this implement/fix? A Sonos S1 provider that was unloaded kept scanning the network for speakers every 30 minutes, forever. Each provider load runs discovery twice (once while starting up, once right after loading). Every run armed a new "scan again in 30 minutes" timer on top of the previous one without cancelling it, and unloading the provider could only cancel the one timer it still knew about. The leftover timer stayed alive, and every time it fired it started another scan and armed itself again — so an unloaded provider never stopped. If the provider had been disabled or removed, those scans also re-connected to the speakers, which is the leak that #5433 fixed coming back through another route. Each reload left another one of these behind. Discovery is now scheduled through the server's own timer helper under a fixed id, so a new run replaces the previous one instead of stacking. Unloading cancels a pending scan as well as one that already started, and a scan that is already talking to the network can no longer schedule itself again on the way out. **Related issue (if applicable):** - n/a — found while reviewing the discovery/unload path after #5433 ## Types of changes <!-- Tick exactly one box. CI (.github/workflows/pr-labels.yaml) derives the label from the ticked box and applies it automatically; the release-notes generator uses that same label to slot this change into the next release notes. --> - [ ] Bugfix (non-breaking change which fixes an issue) — `bugfix` - [ ] New feature (non-breaking change which adds functionality) — `new-feature` - [ ] Enhancement to an existing feature — `enhancement` - [ ] New music/player/metadata/plugin provider — `new-provider` - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) — `breaking-change` - [ ] Refactor (no behaviour change) — `refactor` - [ ] Documentation only — `documentation` - [x] Maintenance / chore — `maintenance` - [ ] CI / workflow change — `ci` - [ ] Dependencies bump — `dependencies` ## Checklist - [x] The code change is tested and works locally. - [x] `pre-commit run --all-files` passes. - [x] `pytest` passes, and tests have been added/updated under `tests/` where applicable. - [ ] For changes to shared models, the companion PR in `music-assistant/models` is linked. - [ ] For changes affecting the UI, the companion PR in `music-assistant/frontend` is linked. - [x] I have read and complied with the project's [AI Policy](https://github.com/music-assistant/.github/blob/main/AI_POLICY.md) for any AI-assisted contributions. - [ ] I have [raised a PR against the documentation repository](https://github.com/music-assistant/music-assistant.io/blob/main/CONTRIBUTING.md) targeting the main or beta branch as appropriate.