66 67 68 69 70 71 multiple bugs #72

Merged
FrauJulian merged 6 commits from 66-67-68-69-70-71-multiple-bugs into main 2026-06-22 10:43:28 +00:00
2 changed files with 30 additions and 1 deletions
Showing only changes of commit a811feaede - Show all commits
+9 -1
View File
5
@@ -227,7 +227,15 @@ export default class AudioManager {
}
this.renewTimer = setTimeout(() => {
void this.start();
void this.start().catch(() => {
this.clearRenewTimer();
this.stopCurrentPlayback();
this.audioPlayer.stop(true);
this.connection?.disconnect();
this.connection?.destroy();
this.connection = undefined;
this.playbackState = 'stopped';
});
}, renewIntervalMs);
if (typeof this.renewTimer.unref === 'function') {
+21
View File
@@ -298,6 +298,27 @@ describe('AudioManager', () => {
expect(startSpy).toHaveBeenCalledTimes(1);
});
it('cleans up when renewal restart fails', async () => {
jest.useFakeTimers();
const manager = new AudioManager({
connection: connectionOptions,
source: liveStreamSource,
renewIntervalMs: 10_000,
});
const startSpy = jest.spyOn(manager, 'start').mockRejectedValue(new Error('renewal failed'));
await manager.connect();
jest.advanceTimersByTime(10_000);
await Promise.resolve();
expect(startSpy).toHaveBeenCalledTimes(1);
expect(mockAudioPlayer.stop).toHaveBeenCalledWith(true);
expect(mockConnection.destroy).toHaveBeenCalled();
expect(manager.state).toBe('stopped');
expect(jest.getTimerCount()).toBe(0);
});
it('clears existing renewal timer before reconnecting', async () => {
jest.useFakeTimers();