From 44a0358b0ceef33cd8bf8e86f32676058c6da9d1 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Mon, 3 Aug 2026 09:33:29 +0700 Subject: [PATCH] =?UTF-8?q?fix(voice):=20screen=20share=20restore=20is=20b?= =?UTF-8?q?est-effort=20=E2=80=94=20Discord=20session=20teardown=20race?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GoLive (dank074 Streamer) needs the single voice session; after the stream ends, an automatic @discordjs/voice reconnect often races Discord's session teardown and times out (AbortError). Restore is now best-effort with a 5s delay; if it fails the FE shows disconnected and the user clicks Connect — an accepted tradeoff for one-voice-session-per-user. --- .../modules/voice-recording/screenShareController.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/services/discord-gateway/src/modules/voice-recording/screenShareController.ts b/services/discord-gateway/src/modules/voice-recording/screenShareController.ts index 42f3764..7da7efd 100644 --- a/services/discord-gateway/src/modules/voice-recording/screenShareController.ts +++ b/services/discord-gateway/src/modules/voice-recording/screenShareController.ts @@ -127,17 +127,19 @@ export class ScreenShareController { /* already gone */ } if (this.restoreVoice) { - // Wait for Discord to fully release the Streamer's voice session - // before re-joining with @discordjs/voice — an immediate join races - // the session teardown and times out with AbortError. + // Best-effort restore after a short delay. Discord often needs the + // Streamer's session fully torn down before @discordjs/voice can + // re-join; if that races, the reconnect times out — the FE shows + // disconnected and the user just clicks Connect again. This is an + // accepted UX tradeoff for GoLive (single voice session per user). setTimeout(() => { Promise.resolve(this.restoreVoice(status)).catch((err) => { this.logger.warn( { error: err instanceof Error ? err.message : String(err) }, - "Failed to restore voice connection after screen share", + "Failed to restore voice connection after screen share (user can reconnect manually)", ); }); - }, 4000); + }, 5000); } }; const done = playStream(output, this.streamer, {