Skip to content

AudioPlayer does not get removed from DataStore in some situations #11039

@NutchapolSal

Description

@NutchapolSal

Which package is this bug report for?

voice

Issue description

For some reason, audioPlayer.stop() seems to cause the node process to never exit when called after destroying voice connection(s?) or not letting the event loop run for a bit before destroying voice connection(s?).

When ran in a debugger and pressing pause after the "cleanup" code has run, it will pause somewhere inside DataStore, and inspecting the variables shows that the AudioPlayer does not get removed from the list of active AudioPlayers even though stop() was called.

After seeing some setTimeout and setIntervals, I guessed that stopping audio player and destroying a voice connection back-to-back might cause issues, so by putting a sleep in-between, it does solve the problem and no longer hangs after "cleanup". It does look like a workaround so it should be fixed or at the very least be documented somewhere.

audioPlayerHangSample.zip

Code sample

// Please see the zip file for complete reproducible sample

Versions

  • @discordjs/voice v0.18.0
  • discord.js v14.21.0
  • Node v24.2.0
  • Typescript v5.8.3

Issue priority

Medium (should be fixed soon)

Which partials do you have configured?

No Partials

Which gateway intents are you subscribing to?

GuildVoiceStates

I have tested this issue on a development release

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions