🐛 [BUG]: Clean up stale voice connection when connect() fails #66

Closed
opened 2026-06-22 09:33:00 +00:00 by FrauJulian · 0 comments
FrauJulian commented 2026-06-22 09:33:00 +00:00 (Migrated from github.com)

Description

AudioManager.connect() creates and subscribes a new voice connection, then awaits entersState(...Ready...). If that await rejects, for example on a timeout, the new connection remains stored on the manager and playbackState remains connecting.

Evidence:

  • src/audio-manager.ts:83 sets playbackState = 'connecting'
  • src/audio-manager.ts:86 assigns this.connection = joinVoiceChannel(...)
  • src/audio-manager.ts:92 awaits readiness without cleanup on rejection

Impact: callers can observe isConnected === true even though readiness failed, and the Discord voice connection can stay alive until the process or caller explicitly disposes the manager.

Acceptance Criteria

  • If entersState rejects, the newly-created connection is destroyed or disconnected.
  • this.connection is cleared when the connection was not ready.
  • The manager leaves a consistent state such as stopped or idle after a failed connect attempt.
  • The original connection failure still rejects to the caller.
  • Add a focused test that mocks entersState rejection and asserts connection cleanup plus final state.
## Description `AudioManager.connect()` creates and subscribes a new voice connection, then awaits `entersState(...Ready...)`. If that await rejects, for example on a timeout, the new connection remains stored on the manager and `playbackState` remains `connecting`. Evidence: - `src/audio-manager.ts:83` sets `playbackState = 'connecting'` - `src/audio-manager.ts:86` assigns `this.connection = joinVoiceChannel(...)` - `src/audio-manager.ts:92` awaits readiness without cleanup on rejection Impact: callers can observe `isConnected === true` even though readiness failed, and the Discord voice connection can stay alive until the process or caller explicitly disposes the manager. ## Acceptance Criteria - If `entersState` rejects, the newly-created connection is destroyed or disconnected. - `this.connection` is cleared when the connection was not ready. - The manager leaves a consistent state such as `stopped` or `idle` after a failed connect attempt. - The original connection failure still rejects to the caller. - Add a focused test that mocks `entersState` rejection and asserts connection cleanup plus final state.
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: fraujulian/Discord-Audio-Stream#66