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

test: add test case for reproducible bug #6059

Closed

Conversation

li-kai
Copy link

@li-kai li-kai commented Mar 18, 2020

This adds a test case for apollographql/react-apollo#3425. This is intended to fail as it is trying to reproduce the bug.

Context

Despite an update occurring, this bug causes the query's loading to remain true. It happens when we:

  1. Make a query with variable a.
  2. Skip a query.
  3. Make a query with variable b. This query's result is the same as step 1's result.

Tracing this bug

This is roughly the call stack for step 3 mentioned above:

  1. useQuery
  2. useBaseQuery
  3. QueryData.execute
  4. QueryData.updateObservableQuery
  5. ObservableQuery.setOptions
  6. ObservableQuery.setVariables
  7. QueryManager.fetchQuery
  8. QueryManager.fetchRequest
  9. observable's map and complete callbacks are called
  10. ObservableQuery's observer's next is called
  11. ObservableQuery.isDifferentFromLastResult

Note that since the new and old data is the same despite having different query variables, step 11 ObservableQuery's isDifferentFromLastResult will return false.

This causes the ObservableQuery's observers' to not be called. QueryData's currentObservable.subscription does not trigger and the component does not update.

Fixing the bug

This is where I need help. I am not sure what would be the proper fix. Here a few ideas:

  • Add previousVariables to ObservableQuery and compare them in isDifferentFromLastResult
  • Mark the data as stale when a skip happens
  • Trigger something on step 9's complete

@apollo-cla
Copy link

@li-kai: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@li-kai
Copy link
Author

li-kai commented Jun 2, 2020

Solved by #6120

@li-kai li-kai closed this Jun 2, 2020
@li-kai li-kai deleted the deeply-equivalent-bug-test branch June 2, 2020 02:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants