-
Notifications
You must be signed in to change notification settings - Fork 408
Sending a message in an empty room linked chunk makes it look empty #6391
Copy link
Copy link
Labels
Description
I've seen this in the ElementX apps: when sending a message in a room while it was empty (never back-paginated), it could happen that my message would be lonely in the room, and that previous room messages would never appear.
The following integration test reproduces it easily:
#[async_test]
async fn test_backpaginate_while_sending() {
let server = MatrixMockServer::new().await;
let client = server.client_builder().build().await;
let event_cache = client.event_cache();
event_cache.subscribe().unwrap();
let room_id = room_id!("!omelette:fromage.fr");
let room = server.sync_joined_room(&client, room_id).await;
let (room_event_cache, _drop_handles) = room.event_cache().await.unwrap();
let (events, room_stream) = room_event_cache.subscribe().await.unwrap();
assert!(events.is_empty());
assert!(room_stream.is_empty());
// Send an event in this room with the send queue (so that it's saved in the
// event cache store).
server.mock_room_state_encryption().plain().mount().await;
server.mock_room_send().ok(event_id!("$1")).mock_once().mount().await;
room.send_queue()
.send(RoomMessageEventContent::text_plain("Hello, World!").into())
.await
.unwrap();
// Then if I backpaginate,
let outcome = room_event_cache.pagination().run_backwards_once(20).await.unwrap();
let BackPaginationOutcome { reached_start, .. } = outcome;
// The event cache can't know whether this is the start or not, and it shouldn't
// assume so.
assert!(reached_start.not());
}Reactions are currently unavailable