Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch events that read receipts point to if we don't have them #3960

Closed
wants to merge 6 commits into from

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Dec 14, 2023

As the comment hopefully explains, this is a giant hack to work around lack of MSC3981 support and hopefully remove some spurious unread dots on threads. With this code, the unread dots appear briefly and then go away again once the event in question is fetched which is not fantastic but better then a perma-stuck dot.

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Here's what your changelog entry will look like:

🐛 Bug Fixes

  • Fetch events that read receipts point to if we don't have them (#3960).

As the comment hopefully explains, this is a giant hack to work around
lack of MSC3981 support and hopefully remove some spurious unread dots
on threads. With this code, the unread dots appear briefly and then go
away again once the event in question is fetched which is not fantastic
but better then a perma-stuck dot.
@dbkr dbkr marked this pull request as ready for review December 14, 2023 18:15
@dbkr dbkr requested a review from a team as a code owner December 14, 2023 18:15
@dbkr dbkr requested review from richvdh and t3chguy December 14, 2023 18:15
* in the delicious Typescript fumes.
*/
private async checkForMissingReceiptEvent(): Promise<void> {
if (this.isCheckingForMissingReceiptEvent) return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it might want to queue/debounce rather than drop given the async action may be looking for eventId123 when the RR has moved onto eventId456 via a gappy sync during startup

Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to say I'm not enthusiastic about this hack. We already have millions of /event/ requests to work around some other failure to land an MSC; it causes load on the server to serve all the requests, and quite a lot of load on the client in terms of making the requests, attempting to decrypt them, failing to decrypt them, checking key backup, etc etc.

I can see the need for a temporary workaround for lack of MSC3981 but my concern is that, as soon as this lands, the problem is out of sight and it's just another large nail in the coffin of Element's performance that we never get round to doing anything about.

Is there a world in which we can instead prioritise enabling MSC3981, and maybe make this hack opt-in to help test it?

@@ -624,6 +626,8 @@ export class Thread extends ReadReceipt<ThreadEmittedEvents, ThreadEventHandlerM
}
}

this.checkForMissingReceiptEvent();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it deliberate that this lacks an await? If so, might be good to comment it to highlight and explain why.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't, but it now has the throttle where the wrapper doesn't return a promise.


try {
const myThreadedReceipt = this.getLatestReceipt(this.client.getUserId()!, true);
if (myThreadedReceipt && this.timeline.length > 0 && !this.findEventById(myThreadedReceipt.eventId)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the condition on timeline.length ? A comment would help.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point: added.

dbkr added 2 commits December 15, 2023 16:50
involves adding a throttle function (manually to avoid a dependency
on lodash).
@dbkr
Copy link
Member Author

dbkr commented Dec 15, 2023

I have to say I'm not enthusiastic about this hack. We already have millions of /event/ requests to work around some other failure to land an MSC; it causes load on the server to serve all the requests, and quite a lot of load on the client in terms of making the requests, attempting to decrypt them, failing to decrypt them, checking key backup, etc etc.

I can see the need for a temporary workaround for lack of MSC3981 but my concern is that, as soon as this lands, the problem is out of sight and it's just another large nail in the coffin of Element's performance that we never get round to doing anything about.

Is there a world in which we can instead prioritise enabling MSC3981, and maybe make this hack opt-in to help test it?

Mm, I share your thoughts, especially having the existing set of thread related things which have gained odd workarounds for lack of server support and then presumably been forgotten. I've picked up 3981 and I don't think anything should actually stand in its way now. Synapse's impl is, afacis, correct, so it really should just be a question of FCPing, getting ticks and then turning the flag on in Synapse by default I think.

As a counterpoint, it should be fairly minimal nail as it will only trigger for specific threads that are broken, but yeah, straws and camels and all that.

If we were to make it opt-in I think it would just be for people that were desperate to unstick the unread dots: I don't really think it would help test anything as the impl is sufficiently different between this and actually having MSC3981.

to make sonarcloud happy
@dbkr
Copy link
Member Author

dbkr commented Dec 18, 2023

So the conclusion here is that we're not going to merge this. Obviously it's still here if we do need to change our minds, but lets concentrate on trying to get the MSC through so we can get a synapse out with 3981 on by default in Jan.

@dbkr dbkr closed this Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants