matrix-org / matrix-rust-sdk

Matrix Client-Server SDK for Rust
Apache License 2.0
1.22k stars 246 forks source link

Weird timeline API behaviour #3190

Open ara4n opened 7 months ago

ara4n commented 7 months ago

I just had a go at implementing the timeline API in my experimental rust-sdk on Web test jig (aurora). I'm seeing very strange behaviour, which maps onto reported bugs on Element X. If I use the API via:

    let Ok(ui_room) = room_list_service.room(&id).await else {
        return Err(Error::Other(anyhow!("couldn't get room")));
    };

    let builder = match ui_room.default_room_timeline_builder().await {
        Ok(builder) => builder,
        Err(err) => {
            return Err(Error::Other(anyhow!("error when getting default timeline builder: {err}")));
        }
    };

    if let Err(err) = ui_room.init_timeline_with_builder(builder).await {
        return Err(Error::Other(anyhow!("error when creating default timeline: {err}")));
    }

    let (items, stream) = ui_room.timeline().unwrap().subscribe().await;

    // and then keep calling:
    let diff = stream.next().await.ok_or(anyhow!("no diffs"))?;

Then I get the following behaviour:

In other words, the bugs are:

c.f. https://github.com/matrix-org/matrix-rust-sdk/issues/1103 for known limitations of the timeline API, which doesn't look to include these.

Hywan commented 7 months ago

The Clear is “normal“ because the server replies with a limited flag. With EventCache coming, we won't need to clear the timeline anymore.

bnjbvr commented 1 week ago

We assign new unique_ids to the same items (probably not a disaster given we just Cleared the previous ones), but it's unsetlling to see the same items turning up with different ids.

I've checked this one because this shouldn't happen anymore. If it does, please provide a code example showing how to trigger it. The unique IDs are about to gain in importance with #4093, so we need them to be super-stable.