From 56e5d5e3d2e191add0aafb5c89be62f59f33710c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Tue, 20 Jul 2021 18:38:17 +0200 Subject: [PATCH] fix: add warning for strange bug --- src/client_server/sync.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client_server/sync.rs b/src/client_server/sync.rs index 65922be..7ab27d9 100644 --- a/src/client_server/sync.rs +++ b/src/client_server/sync.rs @@ -1,5 +1,5 @@ use crate::{database::DatabaseGuard, ConduitResult, Database, Error, Result, Ruma, RumaResponse}; -use log::error; +use log::{error, warn}; use ruma::{ api::client::r0::{sync::sync_events, uiaa::UiaaResponse}, events::{room::member::MembershipState, AnySyncEphemeralRoomEvent, EventType}, @@ -262,9 +262,12 @@ async fn sync_helper( db.rooms .pdu_shortstatehash(&pdu.1.event_id) .transpose() - .expect("all pdus have state") + .ok_or_else(|| { + warn!("PDU without state: {}", pdu.1.event_id); + Error::bad_database("Found PDU without state") + }) }) - .transpose()?; + .transpose()?.transpose()?; // Calculates joined_member_count, invited_member_count and heroes let calculate_counts = || {