-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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: removeQuery not removing a fetch's reject fn, mistakenly triggering "store reset when query in flight" error when store resets #4409
Merged
benjamn
merged 5 commits into
master
from
chang/fix/store-reset-while-query-in-flight-map-rejectFns
Feb 4, 2019
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
benjamn
requested changes
Feb 4, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, just a couple comments to update!
@@ -1088,12 +1091,10 @@ export class QueryManager<TStore> { | |||
let resultFromStore: any; | |||
let errorsFromStore: any; | |||
|
|||
let rejectFetchPromise: (reason?: any) => void; | |||
|
|||
return new Promise<ApolloQueryResult<T>>((resolve, reject) => { | |||
// Need to assign the reject function to the rejectFetchPromise variable | |||
// in the outer scope so that we can refer to it in the .catch handler. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this comment now (yay).
8942220
to
5e7d501
Compare
5e7d501
to
6d27d05
Compare
@benjamn updated and ready for re-review 🙏 |
benjamn
approved these changes
Feb 4, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
removeQuery
was previously only callingunsubscribe
on an operation's subscription, which doesn't trigger theerror
orcomplete
handlers, thus the promise'sreject
function is not cleaned up (removed fromfetchQueryRejectFns
)This PR changes
fetchQueryRejectFns
into aMap
, and modifiesremoveQuery
to delete an operation's associated reject fns from that mapConfirmed to have fixed the repo in #3555 (cloned it and linked a local apollo-client to the project)
Should also fix #3766 (although don't have a repro that exactly matches the submitted bug flow), possibly #2919
Might not fix #3792 (it sounds like another cleanup besides removing from
fetchQueryRejectFns
needs to happen)