resetStore: Store reset while query was in flight.
See original GitHub issueIntended outcome:
resetStore
without errors being thrown.
Actual outcome:
I’m running into an issue when calling resetStore
after a logout scenario. I think I understand the reasoning, but in my case I can’t seem to find a workable way around it, and something else odd is happening:
fetchQueryPromises
in snippet above is a Map
, with values of {promise,reject,resolve}
, so I look inside to see what they are:
const promises = Array.from(this.fetchQueryPromises.values()).map(x => x.promise)
My plan was to await Promise.all(promises)
before calling resetStore
, however, promises
is [undefined]
. For some reason, an entry is added to fetchQueryPromises
without a promise, so I can’t wait for it before resetting.
The actual error Store reset while query was in flight.
looks like it might not actually cause a problem, which was my main concern. But it seems like there should be a way to avoid an error being thrown.
Waiting for existing promises to complete before reset, or exposing a function to allow the user to await them before resetting seems right to me.
Is there a case for calling resetStore
where a thrown error is the right outcome?
Version
- apollo-client@^2.2.0
Issue Analytics
- State:
- Created 6 years ago
- Reactions:25
- Comments:44 (18 by maintainers)
Top GitHub Comments
Still happening on stable as of two weeks ago
Not sure this helps anyone in this thread but I didn’t think to see if
resetStore
was a Promise and turns out it is. For me it was an issue of the requests that were happening right afterresetStore
- not the already in flight ones (I think). So changing thisto this
got rid of the error