[PR #929] [MERGED] fix: bind CLI socket before spawning handler thread #929

Closed
opened 2026-03-03 00:01:30 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/aome510/spotify-player/pull/929
Author: @greqor
Created: 2/12/2026
Status: Merged
Merged: 2/17/2026
Merged by: @aome510

Base: masterHead: fix/cli-connection-refused-race-condition


📝 Commits (1)

  • 30f102b fix: bind CLI socket before spawning handler thread

📊 Changes

3 files changed (+29 additions, -13 deletions)

View changed files

📝 spotify_player/src/cli/client.rs (+20 -11)
📝 spotify_player/src/cli/handlers.rs (+8 -1)
📝 spotify_player/src/main.rs (+1 -1)

📄 Description

Fix: CLI "Connection refused" in stateless mode

PR #921 moved the UDP socket binding inside the socket handler function. This introduced a race condition in the stateless CLI path (no running spotify_player instance): the handler thread is spawned but the socket isn't bound yet when the CLI tries to send its request, resulting in "Connection refused (os error 61)".

Fix

The socket handler now accepts an optional pre-bound socket. In the stateless CLI path, the socket is bound before spawning the thread and passed in directly. The TUI/daemon path is unchanged.

Fixes #927


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/aome510/spotify-player/pull/929 **Author:** [@greqor](https://github.com/greqor) **Created:** 2/12/2026 **Status:** ✅ Merged **Merged:** 2/17/2026 **Merged by:** [@aome510](https://github.com/aome510) **Base:** `master` ← **Head:** `fix/cli-connection-refused-race-condition` --- ### 📝 Commits (1) - [`30f102b`](https://github.com/aome510/spotify-player/commit/30f102be4e6854b9b4e814eb8daa21b34eeea1f7) fix: bind CLI socket before spawning handler thread ### 📊 Changes **3 files changed** (+29 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `spotify_player/src/cli/client.rs` (+20 -11) 📝 `spotify_player/src/cli/handlers.rs` (+8 -1) 📝 `spotify_player/src/main.rs` (+1 -1) </details> ### 📄 Description ## Fix: CLI "Connection refused" in stateless mode PR #921 moved the UDP socket binding inside the socket handler function. This introduced a race condition in the stateless CLI path (no running spotify_player instance): the handler thread is spawned but the socket isn't bound yet when the CLI tries to send its request, resulting in "Connection refused (os error 61)". ### Fix The socket handler now accepts an optional pre-bound socket. In the stateless CLI path, the socket is bound **before** spawning the thread and passed in directly. The TUI/daemon path is unchanged. Fixes #927 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 00:01:30 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-player#929
No description provided.