From 8575f191a0fecbd0ed262a621eed3610aeabb0c3 Mon Sep 17 00:00:00 2001 From: timedout Date: Mon, 27 Apr 2026 23:00:29 +0100 Subject: [PATCH] style: Simplify build_local_dag return --- changelog.d/1711.bugfix | 1 + src/api/server/send.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 changelog.d/1711.bugfix diff --git a/changelog.d/1711.bugfix b/changelog.d/1711.bugfix new file mode 100644 index 000000000..40504da5e --- /dev/null +++ b/changelog.d/1711.bugfix @@ -0,0 +1 @@ +Fixed a bug that caused the server to drop events during processing if several events for the same room were sent in a singular transaction. Contributed by @nex. diff --git a/src/api/server/send.rs b/src/api/server/send.rs index ee5509d7a..5477793d0 100644 --- a/src/api/server/send.rs +++ b/src/api/server/send.rs @@ -309,7 +309,8 @@ async fn build_local_dag( id_origin_ts.insert(event_id.clone(), origin_server_ts); } - let sorted = lexicographical_topological_sort(&dag, &async |node_id| { + debug!(count=dag.len(), "Sorting incoming events with partial graph"); + lexicographical_topological_sort(&dag, &async |node_id| { // Note: we don't bother fetching power levels because that would massively slow // this function down. This is a best-effort attempt to order events correctly // for processing, however ultimately that should be the sender's job. @@ -325,11 +326,12 @@ async fn build_local_dag( Ok((int!(0), MilliSecondsSinceUnixEpoch(ts))) }) .await - .map_err(|e| err!("failed to resolve local graph: {e}")); - if let Ok(ref s) = sorted { - assert_eq!(s.len(), pdu_map.len(), "Sorted graph was not the same size as the input graph"); - }; - sorted + .inspect(|sorted| assert_eq!( + sorted.len(), + pdu_map.len(), + "Sorted graph was not the same size as the input graph" + )) + .map_err(|e| err!("failed to resolve local graph: {e}")) } async fn handle_room(