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

Fix ObservableQuery result dirty check with last.reportedResult #9844

Conversation

javier-garcia-meteologica
Copy link
Contributor

When notifyOnNetworkStatusChange is enabled some watchQueries get stuck in loading: true, partial: true after calling reobserve/setVariables even if the underlying network request has already returned a successful result.

In particular, this bug happens when a reobserved query returns the same data with the new variables as before, or when the query is simply refreshed.

1: loading: false, data           ->   isDifferentFromLastResult=true, savedAsLastResult=true
2: loading: true, partial: true   ->   isDifferentFromLastResult=true, savedAsLastResult=false
3: loading: false, data           ->   isDifferentFromLastResult=false, savedAsLastResult=false, suppressed

In this PR I create the variable last.reportedResult to keep track of last reported result, which may be different than last.result. It avoids leaving queries stuck in loading=true forever.

Related to #9367

Checklist:

  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

@javier-garcia-meteologica javier-garcia-meteologica force-pushed the fix_observable_query_last_result_dirty_check branch from 8eebf09 to b2e4eb0 Compare July 1, 2022 12:56
@meteomaragliano
Copy link

@jpvajda any updates on this issue?

@jpvajda
Copy link
Contributor

jpvajda commented Jul 29, 2022

@meteomaragliano hello! Thanks for the follow up, I'll see if I can get someone from the team to review this PR soon.

@javier-garcia-meteologica
Copy link
Contributor Author

I just run the test of this PR on the main branch and it passed. The problem addressed by this PR seems to be fixed in recent versions of apollo client.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🏓 awaiting-team-response requires input from the apollo team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watch queries are stuck in loading: true, partial: true when notifyOnNetworkStatusChange is enabled
3 participants