-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Fix notifications not being sent on decryption correction #1992
base: dev
Are you sure you want to change the base?
Fix notifications not being sent on decryption correction #1992
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
25e4699
to
80b8526
Compare
const handleUnreadEvent: RoomEventHandlerMap[RoomEvent.UnreadNotifications] = () => { | ||
handleTimelineEvent(mEvent, room, toStartOfTimeline, removed, data); | ||
room.removeListener(RoomEvent.UnreadNotifications, handleUnreadEvent); | ||
}; | ||
room.on(RoomEvent.UnreadNotifications, handleUnreadEvent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you are removing the listener inside event handler, it feels like to me that following change may lead to memory leaks where the event handler is set but never gets removed because you never hear from it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is something I did not consider. I don't really know how to tackle this - my only idea would be to remove the listener after some time. Or I could change it such that for each room there will be at most one listener which would still add memory overhead but constant in the number of rooms the user joined 🤔
Description
Fixes #1892
My analysis in the issue actually seems to be wrong. The root cause for this issue is not the cache but the fact that the matrix-js-sdk sends a timeline event before calling the fixNotificationCountOnDecryption function (see https://github.com/matrix-org/matrix-js-sdk/blob/da044820d7d3255e41e403bfbd035bf7b90ddd6a/src/client.ts#L10322). This leads to the edge case that cinny returns in the sendTimelineEvent function as the counter is 0 before it is corrected to 1.
Type of change
Checklist: