Androz2091 / Androz2091/discord-player
Track ends almost instantly (DAVE MLS commit processed after track finished)
- Ngôn ngữ chính
- TypeScript
- Star
- 638
- Fork
- 197
- Merge trung bình
- 2 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
## Bug: Track ends almost instantly (playbackDuration ~100-200ms) — MLS commit processed AFTER track already marked finished
### Describe the bug
After a fresh restart of my bot process (or after the host VM reboots), tracks stop playing almost immediately — `playbackDuration` is only around 100–200ms before the player marks the track as "finished" and moves to `idle`. This happens with **both SoundCloud and YouTube** sources, so it doesn't seem to be extractor-specific.
Looking at the debug logs, the `speaking:1` → `speaking:0` events and the "Track marked as finished" event fire **before** the DAVE MLS commit has finished processing:
```
[PLAYER DEBUG] state change: to "playing"
[PLAYER DEBUG] [NW] [WS] >> {"op":5,"d":{"speaking":1,...}}
[PLAYER DEBUG] [NW] [WS] >> {"op":5,"d":{"speaking":0,...}}
[PLAYER DEBUG] Track {...} was marked as finished
[PLAYER DEBUG] state change: to "idle"
[PLAYER DEBUG] [NW] [WS] << [bin] opcode 29, seq 6, ... bytes
[PLAYER DEBUG] [NW] [DAVE] MLS commit processed (transition id: 0)
```
Note that the MLS commit is processed **after** the track has already ended. This suggests a race condition where the audio player begins dispatching frames before the DAVE E2EE session/key negotiation has actually completed.
Interestingly, this issue only started appearing after restarting the bot process / rebooting the host VM. A long-running process (that had presumably been started before the DAVE-related package updates) continued to play music normally for an extended period without this issue. Once the process (and the underlying VM) was restarted, the issue appeared consistently on every track, across multiple different tracks and sources.
### To Reproduce
1. Run a bot using `discord-player@7.2.0`, `discord-voip@7.2.0`, `@snazzah/davey@0.1.12`
2. Join a voice channel and play any track (tested with both SoundCloud and YouTube sources)
3. Observe that playback stops almost instantly (~100-200ms), regardless of source
4. Enable debug logging and note that "MLS commit processed" appears in the log *after* the track has already been marked as finished
### Expected behavior
The player should wait for the DAVE E2EE session (MLS commit) to be fully established before beginning to dispatch audio frames, so tracks play back normally for their full duration.
### Environment
- discord-player: 7.2.0
- discord-voip: 7.2.0
- @discord-player/extractor: 7.2.0
- @snazzah/davey: 0.1.12
- discord.js: ^14.16.3
- Node.js: v20.20.2
- OS: Ubuntu (Google Cloud Compute Engine VM)
- Process manager: pm2
### Additional context
- Verified this is not a resource-starvation issue: `top`/`free -h` show CPU idle at ~98% and plenty of free memory during playback attempts.
- Verified this is not a network/IP issue: external IP was confirmed unchanged before/after the issue appeared.
- Verified this is not SoundCloud-specific: the same near-instant cutoff happens with YouTube sources too.
- The issue appears consistently after a fresh process start / VM reboot, but did not occur on a long-running process prior to restart — suggesting a timing-sensitive race condition that is more likely to trigger during "cold start" conditions (fresh network stack, no JIT warm-up, etc.), though the underlying bug is presumably present regardless of uptime.
- Discord's DAVE E2EE protocol became a mandatory requirement for non-stage voice channels starting March 2, 2026, so this is likely an edge case in the relatively new DAVE support added to discord-player/discord-voip.
Full debug logs available on request (redacted server/session/token/secret key values from the ones I have).
Hướng dẫn đóng góp
Hướng nghiên cứu
Reproduce the issue with discord-player@7.2.0, discord-voip@7.2.0, and @snazzah/davey@0.1.12 while capturing debug logs. Trace the ordering between audio frame dispatch, the speaking events, track completion, and the DAVE MLS commit; done means playback waits for the DAVE session to finish and tracks play normally across SoundCloud and YouTube.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- node.js, typescript
- Lĩnh vực
- audio-video-rtc
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100