Skip to content

Fix Sendspin reconnect races and add initial visualizer role support#3431

Merged
MarvinSchenkel merged 10 commits intodevfrom
fix/sendspin-reconnect-race
Mar 20, 2026
Merged

Fix Sendspin reconnect races and add initial visualizer role support#3431
MarvinSchenkel merged 10 commits intodevfrom
fix/sendspin-reconnect-race

Conversation

@maximmaxim345
Copy link
Copy Markdown
Member

@maximmaxim345 maximmaxim345 commented Mar 19, 2026

Sendspin players that reconnect quickly could hit race conditions in some cases. This is now fixed by discarding stale add/remove tasks.

Additionally, updates aiosendspin to 4.4.0 with:

Copilot AI review requested due to automatic review settings March 19, 2026 14:25
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 19, 2026

🔒 Dependency Security Report

📦 Modified Dependencies

music_assistant/providers/sendspin/manifest.json

Added:

Removed:

Unchanged dependencies
  • av ==16.1.0

The following dependencies were added or modified:

diff --git a/requirements_all.txt b/requirements_all.txt
index 890418fb..5c21cfea 100644
--- a/requirements_all.txt
+++ b/requirements_all.txt
@@ -11,7 +11,7 @@ aiojellyfin==0.14.1
 aiomusiccast==0.15.0
 aiortc>=1.6.0
 aiorun==2025.1.1
-aiosendspin==4.3.4
+aiosendspin==4.4.0
 aioslimproto==3.1.7
 aiosonos==0.1.9
 aiosqlite==0.22.1

New/modified packages to review:

  • aiosendspin==4.4.0

🔍 Vulnerability Scan Results

No known vulnerabilities found
✅ No known vulnerabilities found


Automated Security Checks

  • Vulnerability Scan: Passed - No known vulnerabilities
  • Trusted Sources: All packages have verified source repositories
  • Typosquatting Check: No suspicious package names detected
  • License Compatibility: All licenses are OSI-approved and compatible
  • Supply Chain Risk: Passed - packages appear mature and maintained

Manual Review

Maintainer approval required:

  • I have reviewed the changes above and approve these dependency updates

To approve: Comment /approve-dependencies or manually add the dependencies-reviewed label.

@maximmaxim345 maximmaxim345 added the dependencies-reviewed Indication that any added or modified/updated dependencies on a PR have been reviewed label Mar 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Sendspin integration to aiosendspin==4.4.0, adds handling for refreshed client “hello” attributes (including the draft visualizer role), and hardens Sendspin player registration/unregistration against quick reconnect race conditions by discarding stale tasks.

Changes:

  • Bump aiosendspin to 4.4.0 in both global requirements and the Sendspin provider manifest.
  • Add per-client event versioning/task tracking in the Sendspin provider to skip stale add/remove work and reduce reconnect races.
  • Add ClientUpdatedEvent handling and refactor SendspinPlayer to refresh attributes from updated hello payloads and manage event subscriptions more safely.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
requirements_all.txt Updates pinned aiosendspin dependency to 4.4.0.
music_assistant/providers/sendspin/manifest.json Updates provider-level requirement pin for aiosendspin to 4.4.0.
music_assistant/providers/sendspin/provider.py Adds stale-task suppression for add/remove and introduces client-updated handling.
music_assistant/providers/sendspin/player.py Adds refreshable hello-derived attributes and consolidates subscribe/unsubscribe logic for callbacks.

Comment thread music_assistant/providers/sendspin/provider.py Outdated
Comment thread music_assistant/providers/sendspin/provider.py
Comment thread music_assistant/providers/sendspin/provider.py
@maximmaxim345 maximmaxim345 changed the title Update aiosendspin to 4.4.0 (with initial visualizer support) and fix register race conditions Fix Sendspin reconnect races and add initial visualizer role support Mar 19, 2026
Copilot AI review requested due to automatic review settings March 19, 2026 15:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Sendspin provider to reduce reconnect race conditions by discarding stale add/remove work, and bumps the Sendspin client library to pick up refreshed-hello handling and initial draft visualizer role availability.

Changes:

  • Bump aiosendspin from 4.3.4 to 4.4.0 in both the global requirements and the Sendspin provider manifest.
  • Add per-client event versioning/in-flight bookkeeping to skip stale add/remove tasks during rapid reconnects.
  • Add handling for ClientUpdatedEvent to refresh player attributes when the client hello payload changes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
requirements_all.txt Updates pinned aiosendspin version to 4.4.0.
music_assistant/providers/sendspin/provider.py Adds stale-task prevention for reconnect races and handles ClientUpdatedEvent.
music_assistant/providers/sendspin/player.py Adds callback subscribe/unsubscribe helpers and supports refreshing player attributes from updated client info.
music_assistant/providers/sendspin/manifest.json Updates provider-scoped aiosendspin requirement to 4.4.0.
Comments suppressed due to low confidence (1)

music_assistant/providers/sendspin/provider.py:259

  • unload() sets _unloading = True but does not cancel/await any in-flight add/remove tasks that already passed the _unloading check, so they can still run and (re-)register/unregister players after the provider has started unloading. Consider tracking the created client-event tasks (e.g., with task_id per client) and cancelling/awaiting them during unload, and/or re-check _unloading after awaits inside the handlers before mutating player registration state.
        self._unloading = True
        player_ids = [player.player_id for player in self.players]
        # Disconnect all clients before stopping the server
        clients = list(self.server_api.clients)
        connected_clients = []
        disconnect_tasks = []

Comment thread music_assistant/providers/sendspin/provider.py
@MarvinSchenkel MarvinSchenkel merged commit 0cd7344 into dev Mar 20, 2026
10 checks passed
@MarvinSchenkel MarvinSchenkel deleted the fix/sendspin-reconnect-race branch March 20, 2026 11:49
OzGav pushed a commit that referenced this pull request Mar 21, 2026
…3431)

* fix(sendspin): harden reconnect lifecycle

* feat: handle `ClientUpdatedEvent` in sendspin provider

When a client reconnects with a changed hello payload, refresh
the player's device info and state without a full reattach cycle.

* chore(sendspin): bump aiosendspin to 4.4.0

* fix(sendspin): preserve client-updated player state

* refactor(sendspin): drop direct `_evaluate_protocol_links` call

This is now handled internally by `register_or_update`.

* fix(sendspin): guard `_handle_client_updated` against unload

* fix(sendspin): check for stale event before registering player

* fix(sendspin): preserve reconnect state across client events

* fix(sendspin): preserve bridge identity on client update
OzGav pushed a commit that referenced this pull request Mar 21, 2026
…3431)

* fix(sendspin): harden reconnect lifecycle

* feat: handle `ClientUpdatedEvent` in sendspin provider

When a client reconnects with a changed hello payload, refresh
the player's device info and state without a full reattach cycle.

* chore(sendspin): bump aiosendspin to 4.4.0

* fix(sendspin): preserve client-updated player state

* refactor(sendspin): drop direct `_evaluate_protocol_links` call

This is now handled internally by `register_or_update`.

* fix(sendspin): guard `_handle_client_updated` against unload

* fix(sendspin): check for stale event before registering player

* fix(sendspin): preserve reconnect state across client events

* fix(sendspin): preserve bridge identity on client update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies-reviewed Indication that any added or modified/updated dependencies on a PR have been reviewed enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants