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

Error when using pagination with realtime query #5442

Open
2 tasks done
tiagosilveiradev opened this issue Feb 17, 2025 · 9 comments
Open
2 tasks done

Error when using pagination with realtime query #5442

tiagosilveiradev opened this issue Feb 17, 2025 · 9 comments
Assignees
Labels
Bug status: confirmed Issue has been reproduced and confirmed as a bug.

Comments

@tiagosilveiradev
Copy link

Can we access your project?

  • I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.

Current Behavior

I have a component used by both pages and other components (such as inside a bottom sheet). This component receives a String parameter, which is used to filter data in a Firestore query with real-time updates enabled ("Listen for changes" toggled). The parameter can be null; if provided, the query applies the filter; otherwise, it does not.

When I call this component from a bottom sheet with a filter parameter, everything works as expected. However, after closing the bottom sheet and navigating to another page with the same component (but without the filter parameter), the query removes the filter. The issue arises because the query starts from the last known position of the query (or the last rendered component) rather than resetting properly.

After inspecting the generated code and debugging, I suspect the issue occurs because the nextPageMarker is not being reset when the bottom sheet is dismissed (or when pop() is called on the active page).

Here is a snippet of the code:

PagingController<DocumentSnapshot?, OrdensServicoRecord>
     _createListViewController(
   Query query,
   DocumentReference<Object?>? parent,
 ) {
   final controller = PagingController<DocumentSnapshot?, OrdensServicoRecord>(
       firstPageKey: null);
   return controller
     ..addPageRequestListener(
       (nextPageMarker) => queryOrdensServicoRecordPage(//Here
         queryBuilder: (_) => listViewPagingQuery ??= query,
         nextPageMarker: nextPageMarker,
         streamSubscriptions: listViewStreamSubscriptions,
         controller: controller,
         pageSize: 25,
         isStream: true,
       ),
     );
 }
}

If I disable the "Listen for changes" option, it does not happen.

Expected Behavior

When the component (or bottom sheet) containing the query is dismissed, and the user navigates to another page that also includes the same component, the query should start from the beginning. It should not continue from the last item that was loaded on the previous page or component.

Steps to Reproduce

  1. Create a component with a parameter;
  2. Put a listview inside of this component;
  3. Put a Firestore query at this listview;
  4. Pass this parameter to the query and check the options "Listen for Changes", "Ignore empty filter values" and "Enable Infinity Scroll"
  5. Create another component with the same parameter of the last component;
  6. Put the query component inside of the new component;
  7. Create a page;
  8. Put the query component inside of this page passing null as a parameter
  9. Create another page;
  10. Inside of the another page create two buttons, one to call a bottomsheet passing a parameter and another navigating to the other page with the query component
  11. Start your app, click to open the bottomsheet
  12. Dismiss the bottomsheet
  13. Navigate to the other page

Reproducible from Blank

  • The steps to reproduce above start from a blank project.

Bug Report Code (Required)

IT4kz/Hqx89Prttc15PTbcZKo2E6Jn56TL07r+5xb0gvIrbyOu9/PffOQBZWYMTiSlNhHFabgj0d7s7GjoSTFfUnFzqaGq5z+sx6ERXvTXq8SpSyPKjpenwnRJ5QJ0id1J6Z2yJTKvNfdGAb3EOpN9itTT7tCZ+/Zwh9f6PHaOI=

Visual documentation

Environment

- FlutterFlow version: 5.2.20
- Platform: Web
- Browser name and version: Chrome 132.0.6834.197 
- Operating system and version affected: Windows 11

Additional Information

It is causing problems to my costumers since it is showing incorrect information, so they think that losses some data and opens a support ticket, and, we need realtime data at all instances of this component, so, disabling realtime is not possible.

@tiagosilveiradev tiagosilveiradev added the status: needs triage A potential issue that has not been confirmed as a bug. label Feb 17, 2025
@tiagosilveiradev
Copy link
Author

Here is a video that exemplifies the problem:
https://drive.google.com/file/d/1qsXNF3JGmJ3lZCKkGmrVTjyLWRGe9Z2w/view?usp=drive_link

Copy link
Collaborator

Hello! 👋

Thanks for reaching out! Could you kindly invite me as a collaborator on the test project? I'd like to try something to help troubleshoot the issue.

You can invite me using this email: [email protected]

Looking forward to your response! 😊

@Alezanello Alezanello self-assigned this Feb 18, 2025
@Alezanello Alezanello removed the status: needs triage A potential issue that has not been confirmed as a bug. label Feb 18, 2025
@tiagosilveiradev
Copy link
Author

Hello! 👋

Thanks for reaching out! Could you kindly invite me as a collaborator on the test project? I'd like to try something to help troubleshoot the issue.

You can invite me using this email: [email protected]

Looking forward to your response! 😊

Done! :D

Copy link
Collaborator

Thank you!

I'll update this ticket soon with more insights!

Copy link
Collaborator

Hello again!

I’ve been testing different approaches, and I noticed that after disabling Infinite Scroll to try something, I encountered several serialization errors. This might be affecting the list and causing it not to refresh as expected.

Could you please check the integrity of your documents to see why this error appears when Infinite Scroll is disabled? This might help identify the root cause and potentially resolve the issue.

Let me know how it goes, and thanks again for your collaboration!

image.png

Also it seems that Infinite Scroll package needs an update because is having some issues about the queries: #2843 (comment)

@tiagosilveiradev
Copy link
Author

Hi,

I’ve resolved the serialization errors by restoring a Firestore backup. The issue occurred because some documents contained an integer value instead of a string due to schema adaptations, and I hadn’t removed those documents.

You should be able to try again now. Let me know if you encounter any issues! PS: I Think that in your tests you are loading the whole collection into memory.

Copy link
Collaborator

Hello again!

It looks like the first results of the bottom sheet were deleted during the backup restore.

List.gif

@tiagosilveiradev
Copy link
Author

I'm so sorry for that, I've created new records with the "LiberadaParaFaturamento" situation, so it should work now. (PS: The document numbers may be different from the ones in the first video.)

Copy link
Collaborator

It looks like I can now confidently mark this as a bug. Please avoid making any changes to the test project for now. I’ll be sending it to the engineering team for further review.

@Alezanello Alezanello added Bug status: confirmed Issue has been reproduced and confirmed as a bug. labels Feb 20, 2025 — with Linear
@Alezanello Alezanello removed their assignment Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug status: confirmed Issue has been reproduced and confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

3 participants