From 95e37004a466bf6e5bc56202ff7c7ac983a4e9b6 Mon Sep 17 00:00:00 2001 From: Pavel Borzenkov Date: Thu, 25 Jul 2024 14:23:45 +0200 Subject: [PATCH] corro-client: add expected and received change ID to MissedChange error We still get them and it's not clear what's going on. Maybe known the actual change IDs will help. --- crates/corro-client/src/sub.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/corro-client/src/sub.rs b/crates/corro-client/src/sub.rs index 74a779b5..cb7039dd 100644 --- a/crates/corro-client/src/sub.rs +++ b/crates/corro-client/src/sub.rs @@ -75,8 +75,8 @@ pub enum SubscriptionError { Http(#[from] http::Error), #[error(transparent)] Deserialize(#[from] serde_json::Error), - #[error("missed a change, inconsistent state")] - MissedChange, + #[error("missed a change (expected: {expected}, got: {got}), inconsistent state")] + MissedChange { expected: ChangeId, got: ChangeId }, #[error("max line length exceeded")] MaxLineLengthExceeded, #[error("initial query never finished")] @@ -148,8 +148,14 @@ where self.last_change_id = *change_id; } if let TypedQueryEvent::Change(_, _, _, change_id) = &evt { - if matches!(self.last_change_id, Some(id) if id.0 + 1 != change_id.0) { - return Poll::Ready(Some(Err(SubscriptionError::MissedChange))); + match self.last_change_id { + Some(id) if id + 1 != *change_id => { + return Poll::Ready(Some(Err(SubscriptionError::MissedChange { + expected: id + 1, + got: *change_id, + }))) + } + _ => (), } self.last_change_id = Some(*change_id); }