From fa92610de40b04a0d803996baea6142eef821c69 Mon Sep 17 00:00:00 2001 From: Tim Vilgot Mikael Fredenberg Date: Fri, 23 Jun 2023 00:11:38 +0200 Subject: [PATCH] refactor(gateway): cleanup dispatch sequence handling Aligns our code with the spec by removing questionable logic that, even if hit, was completely wrong. The code tried to resume with the *new* sequence (instead of the old) and it's not swallowing the, to be, duplicated event. --- twilight-gateway/src/shard.rs | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/twilight-gateway/src/shard.rs b/twilight-gateway/src/shard.rs index 1fde728c93f..f5420b9630b 100644 --- a/twilight-gateway/src/shard.rs +++ b/twilight-gateway/src/shard.rs @@ -1017,27 +1017,8 @@ impl Shard { _ => {} } - // READY *should* be the first received dispatch event (which - // initializes `self.session`), but it shouldn't matter that - // much if it's not. if let Some(session) = self.session.as_mut() { - let last_sequence = session.set_sequence(sequence); - - // If a sequence has been skipped then we may have missed a - // message and should cause a reconnect so we can attempt to get - // that message again. - if sequence > last_sequence + 1 { - tracing::info!( - missed_events = sequence - (last_sequence + 1), - "dispatch events have been missed", - ); - self.session = self - .close(CloseFrame::RESUME) - .await - .map_err(ProcessError::from_send)?; - } - } else { - tracing::info!("unable to store sequence"); + session.set_sequence(sequence); } } Some(OpCode::Heartbeat) => {