question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

client.stop is not the way to prevent "reset store when query is in flight error"

See original GitHub issue

This is probably a documentation issue or might be considered an edge case. When you reset the cache, you often get the error:

Store reset while query was in flight (not completed in link chain)

My solution was to call client.stop() before resetting the store. However, after that, the local cache doesn’t work anymore. It probably requires a full client recreation? Or is this considered a bug.

Intended outcome:

The pattern to correctly reset the store should be clear.

Actual outcome:

It’s not clear how to reset the store and avoid the error.

How to reproduce the issue:

I’ve created an example that reproduces the various cases.

https://codesandbox.io/s/quirky-haslett-db3vj?file=/src/index.js

Versions @apollo/client 3.0.0-beta.48

System: OS: macOS Mojave 10.14.6 Binaries: Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.1/bin/yarn npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm Browsers: Chrome: 81.0.4044.138 Safari: 13.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
hwillsoncommented, May 21, 2020

Thanks for the reproduction @mschipperheyn. ApolloClient.stop() is intended to be called just before destroying the client instance, which explains why the cache stops working. Although this method is public, you shouldn’t really ever have to call it yourself (it’s more for libraries that integrate with Apollo Client that need a way to ensure the QueryManager has been stopped). If you’re using stop then yes you’ll likely have to reinstantiate the client instance.

That being said, the Store reset while query was in flight (not completed in link chain) can definitely be annoying to deal with. We’ll put some thought into a way to improve this.

4reactions
thomasttvocommented, Jul 1, 2021

Found this thread after spending so many hours digging. The error message in the title wasn’t correct, so google couldn’t pick up. The actual error is “Store reset while query is in flight”. Therefore, I’m adding this comment in hope of making this thread SEO friendly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class ApolloClient - Apollo GraphQL Docs
The cache that Apollo Client should use to store query results locally. The recommended cache is InMemoryCache , which is provided by the...
Read more >
Store reset while query was in flight (not completed in link chain)
when I log out my user. the code is const onSignout = async () => { removeToken(); client.cache.reset(); await client.
Read more >
Disable Automatic Client Authentication - Tableau Help
Connected client sessions are managed by OAuth access and refresh tokens. By default, OAuth client tokens reset after a year. If a client...
Read more >
Amazon SQS visibility timeout - Amazon Simple Queue Service
Learn about the visibility timeout, which Amazon SQS uses to prevent ... 120,000 in flight messages (received from a queue by a consumer,...
Read more >
Errors and warnings during Sync - AppSheet Help
If you are seeing this warning repeatedly, check the Performance History to see why the client Sync requests is taking so long to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found