Zaostaly Jezevec
Zaostaly_Jezevec#7829
Joined Nov 14, 2026
- On Moving a user to another voice channel makes them invisible and stuck reconnectingI can reproduce this on a self-hosted instance (API/gateway 2026.1114, desktop 2026.1114.60222 and web 2026.1114.52902) and found the root cause plus a working server-side workaround. Symptom
PATCH /guilds/{g}/members/{u}with{"channel_id": ...}returns 200, the user sees "connecting" (orange), then an error, and after ~5 s the client puts them back in the original channel. Same on desktop and web. Console output (both clients):The server side is fine: no errors in api/gateway/LiveKit, and the token request succeeds. Root cause: a race between two gateway events on the client After a move the gateway sends two events for the moved user almost at once:[VoiceEngineV2AppConnectionHostAdapter] [Warn] Aborting LiveKit room creation after codec probing because attempt is stale {attemptId: 5} at handleVoiceServerUpdateAsync -> ... (VOICE_SERVER_UPDATE was received) [VoiceEngineV2AppConnectionHostAdapter] [Warn] Voice server timeout {guildId, channelId: <target>} [VoiceReconnectionManager] [Info] Attempting to reconnect to last voice channel {channelId: <original>}VOICE_STATE_UPDATE(new channel). The client handles it inMediaEngineFacade.ts(~L1889-1898): it callsdisconnectForChannelMove('server')and, in.finally(),recoverConnectionExpectation(...). That starts a new connection attempt.VOICE_SERVER_UPDATE(token for the new channel). The handler inVoiceEngineV2AppConnectionHostAdapter.tsaccepts it, then awaitsgetRoomVideoDecoderExclusions()and re-checksisLatestConnectionAttempt(attemptId)(~L519-526).
recoverConnectionExpectationand the already running attempt for the token is discarded as stale. The server only sends the token once, so the client waits for aVOICE_SERVER_UPDATEthat never comes again, times out after 5 s and reconnects to the old channel. With a fast, local LiveKit the token seems to arrive right after the state update, so this lost the race every time for us. (This is my reading of the client code, I did not trace the exact event order.) This also matches the "Connection succeeded but attempt is stale, disconnecting" log from other self-hosters in this thread. Workaround that works for us Influxer_gateway/src/guild/voice/guild_voice_move.erl, delay the token dispatch a bit soVOICE_STATE_UPDATEis always handled first. The function already runs in a spawned process, so nothing is blocked:With this single change the move worked on our instance (tested once, moving a user via the API; before the change it failed 3 out of 3 times on desktop and web). The fact that a pure delay fixes it supports the race explanation above. It is only a workaround: a proper fix would make the client tolerate either event order (e.g. not invalidate the attempt that is already waiting on the token for the same target channel), or have the server guarantee the order.- define ( MOVE_TOKEN_DELAY_MS , 500 ). send_captured_voice_server_updates ( GuildId , ChannelId , SessionDataList , GuildPid ) -> timer : sleep ( ?MOVE_TOKEN_DELAY_MS ), lists : foreach ( ... )