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

Implementation can cause major inconsistencies and missed messages #505

Open
nvahalik opened this issue Nov 15, 2023 · 3 comments
Open

Implementation can cause major inconsistencies and missed messages #505

nvahalik opened this issue Nov 15, 2023 · 3 comments

Comments

@nvahalik
Copy link

Hello,

There is a bug which can cause a user to never see some messages in the UI given the way that the Angular SDK is written.

Essentially, the problem is that the current way of handling pagination in the SDK works for only the most simplistic of cases. It doesn't take into account the filters. This can only be explained by way of example:

Let's say that you have 500 channels. And let's also say that you are using a filter of has_unread. Now, there is already a problem where if you have over 100 unread channels this filter doesn't work properly (known issue). But let's assume for a moment that problem isn't in play because we have less than 100 unread channels. For our example, let's also assume that we are loading 10 channels at a time, as it'll make the problem more apparent.

We call channelService.init() and load the initial batch of channels. Assume we have 30 unread channels. We've loaded 10 unread channels. Now, we load the next batch of 10 by calling channelService.loadMoreChannels(). This queries the channels again with the same filter and an offset of 10, since that's the current count of the channel list.

However, let's say that we're responding to messages and respond to 10 of them. We now have 10 channels that have unread messages loaded. So we want load the next 10. So we call channelService.loadMoreChannels() with an offset of 20... but... there are only 20 unread messages. So if we have 20 messages in our channelSubject, when we query the channels again, no channels will be returned since there are none that match the offset.

This can also happen, too, if channels populate via the web socket. Because the client this.channels.length is always used as the offset, it opens up the possibility that the next time the pagination occurs, it will skip or miss channels completely.

@szuperaz
Copy link
Contributor

Thank you for the detailed bug report. I have a fix in mind, which I still have to validate. If that works, you can expect a release with the fix sometime next week. I'll keep you posted either case.

@szuperaz
Copy link
Contributor

Just a clarification: your issue description mentions has_unread filter, but we don't have such filter, has_unread is a sort parameter.

About the first problem, which is that the SDK sets offset incorrectly because it counts channels from WS events as well: this is fixed in [email protected]

About the second problem, which is that offset won't work if the channel order changes between the channel queries: I wasn't able to solve this from the client side. At this time, we don't have a solution for this problem.

@nvahalik
Copy link
Author

nvahalik commented Nov 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants