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 cache-and-network/stale on client.reexecuteOperation queue #669

Merged
merged 4 commits into from
Mar 25, 2020

Conversation

kitten
Copy link
Member

@kitten kitten commented Mar 25, 2020

Fix #668

Summary

This fixes an edge case that was missed in #662.

The queue wasn't marked as being started by the first client.dispatchOperation, which means that the queue is then emptied by the first client.rexecuteOperation call instead. This doesn't cause any issues usually, but with the dedupExchange we'll accidentally deduplicate reissued operations, which are usually used to implement fetching for stale results or cache-and-network operations.

Set of changes

  • Fix queuing behavior in client.dispatchOperation
  • Add test for operation & result ordering
  • Remove client.exchange (private variable)

We need to designate the first dispatch to empty the queue
instead of starting to empty the queue after, which can lead
the next reexecuteOperation call to empty the queue instead.
@changeset-bot
Copy link

changeset-bot bot commented Mar 25, 2020

🦋 Changeset is good to go

Latest commit: 7dce9f5

We got this.

This PR includes changesets to release 1 package
Name Type
@urql/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Collaborator

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, next-urql seems to rely on client.exchange in a test

@kitten kitten force-pushed the fix/client-dispatching-queue branch from 45c451a to 7dce9f5 Compare March 25, 2020 08:54
@kitten kitten merged commit d385454 into master Mar 25, 2020
@kitten kitten deleted the fix/client-dispatching-queue branch March 25, 2020 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query does not refetch when variables change
2 participants