-
Notifications
You must be signed in to change notification settings - Fork 216
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
Race condition between page fetch and item list update causing item duplication #266
Comments
Widget _buildListItemWidget(
} How to prevent the method from calling notifyPageRequestListeners when the paging is ongoing? |
Hi, were you able to resolve this? |
I'm also facing the same issue. |
Please create gist so that we can replicate the issue to fix it. |
I have a page with multiple pagingControllers, each fetching data for it's respective tab, and each with infinite items. I was able to workaround this issue by adding a debouncer to each of the pagination methods passed to
|
We need a working example. @faisalansari0367 asked but no response was given from the reporters. Closing the issue for now, but feel free to reopen. |
Hi, I sincerely apologize for the delay in my response. @faisalansari0367 @EdsonBueno Issue Description While fetching the next page, if the user updates an item's state (for example, changing an item's 'favorite' status), the list state is updated through REC-20230916174545.mp4@EdsonBueno The issue also exists in the WonderWords app. Note: I added a delay to my request to simulate scenarios, which does not mean that the problem rarely occurs. This has happened to me so many times, that even with the QA testing team, I had to copy and modify the package to implement a quick fix. My Solution The |
it does not works on my case.
idk when did the pagingController called another |
I have the same exact issue @Sovann72 , @Ahmed-Omar-Hommir . Were you guys able to find a workaround? |
Hi,
This issue seems to be a race condition that occurs when a new page is being fetched (via addPageRequestListener) and the item list is being updated (via UpdateFavorite).
Here's a brief overview of the situation:
`
pagingController.addPageRequestListener((page) async {
add(GetRestaurants(page));
});
on((event, emit) {
final itemList = pagingController.itemList;
if (itemList == null || itemList.isEmpty) return;
ListRestaurantDM restaurants = ListRestaurantDM(restaurants: itemList);
restaurants = restaurants.updateFavorite(
restaurantId: event.restaurantId,
isFavorite: event.isFavorite,
);
//When updated itemList and the pagingControllerState is "ongoing" the addPageRequestListener listens again for the same page.
pagingController.itemList = restaurants.restaurants;
});
`
The problem occurs when GetRestaurants is called to fetch a new page (which means the state is ongoing), and UpdateFavorite is called concurrently to update the itemList of the pagingController. This results in the same page being called multiple times, leading to item duplication in the list.
This issue only occurs when a page fetch is in progress and the item list is updated simultaneously.
Do you have any recommendations on how to resolve this, or is this something that needs to be addressed within the package itself?
Thank you for your time and assistance.
The text was updated successfully, but these errors were encountered: