-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
🐛 Bug Report: Headless Client Page Based Pagination Error #5053
Comments
I would love to work on this issue. Please assign me |
@Vijaykv5 who are you talking to? I do not have permissions to assign someone to a ticket. |
I'm talking to maintainers mate :) |
Hi there , I believe this issue is fixed. I mean when a new notification is received in your case the API will refetch the data . |
Please let me know if #5011 fixed the issue, closing for now 🙏 |
@scopsy Sry for replying late. The issue seems to persist. I tested it with the following method: I crate a headless client and fetch the first page. In between I trigger new notifications. When I fetch the next page the same notification is returned. I haven't looked at the internals of the headless client yet but the issue seems to be that page based pagination is used instead of cursor based pagination. The seem issue will also be present when using the server api.
test-novu > npx ts-node main.ts test-novu > npx ts-node main.ts
|
@vichustephen Sorry for replying quite late I had some things to take care of. See my previous comment, the issue seems to persist. |
@vichustephen @scopsy I believe this issue still has to be reopened |
Hi @lwuethrich-devedis please let me know client library version that you are using. Are you trying out with the latest version ? |
@vichustephen With the latest version of novu/headless 0.24.1 |
📜 Description
This problem affects the headless client and might affect the prebuilt notification center components as well.
Currently when fetching user notification using
HeadlessService#fetchNotifications
page based pagination is used witha page number and an optional limit.
This returns notifications for a user with notifications sorted by createdAt date descending, so newer notifications are first in list.
However, when new notifications are created this page number has now a wrong offset as the newer notifications are inserted in front of th existing ones. This means fetching the next page will return previously fetched notifications as well.
A cursor based pagination would solve this problem as this is not dependent on the order of elements or if elements are added or deleted. This could be both for the oldest notification fetched as well as for fetching newly created notifications.
👟 Reproduction steps
HeadlessService#fetchNotifications
) with page set to 0👍 Expected behavior
It should return the next notifications given the page and limit correctly.
👎 Actual Behavior with Screenshots
It returns previously fetched notifications as the page number is not correct anymore.
Novu version
Novu SaaS
npm version
No response
node version
No response
📃 Provide any additional context for the Bug.
No response
👀 Have you spent some time to check if this bug has been raised before?
🏢 Have you read the Contributing Guidelines?
Are you willing to submit PR?
None
The text was updated successfully, but these errors were encountered: