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

Prevent unhandled rejections by stopping QueryManager more thoroughly. #4359

Merged
merged 1 commit into from
Jan 22, 2019

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Jan 22, 2019

This commit was extracted from #4337, since the problem it solves seems unrelated to that PR.

The QueryManager#stop method cancels all pending fetches by running this.fetchQueryRejectFns. However, this leads to some unhandled promise rejections during tests, which might go unnoticed because they don't cause the test suite to fail.

This commit makes the QueryManager#stop method a bit more aggressive about stopping active queries and unsubscribing from observables, which prevents the unhandled rejections.

The QueryManager#stop method cancels all pending fetches by running
this.fetchQueryRejectFns. However, this leads to some unhandled promise
rejections during tests, which might go unnoticed because they don't cause
the test suite to fail.

This commit makes the QueryManager#stop method a bit more aggressive about
stopping active queries and unsubscribing from observables, which prevents
the unhandled rejections.
@benjamn benjamn self-assigned this Jan 22, 2019
@benjamn benjamn requested a review from hwillson January 22, 2019 19:38
@benjamn benjamn changed the title Fix local test failures by stopping QueryManager more thoroughly. Prevent unhandled rejections by stopping QueryManager more thoroughly. Jan 22, 2019
@@ -953,7 +963,12 @@ export class QueryManager<TStore> {
}

public stopQuery(queryId: string) {
this.stopQueryInStore(queryId);
this.stopQueryNoBroadcast(queryId);
this.broadcastQueries();
Copy link
Member Author

Choose a reason for hiding this comment

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

Reiterating #4337 (comment) here:

This now waits to call this.broadcastQueries() until after the query has been removed, whereas previously this.stopQueryInStore(queryId) would stop the query, call this.broadcastQueries(), then return control to stopQuery, which would finally call this.removeQuery(queryId).

It makes more sense to me to wait until the query has been removed to broadcast queries, but I'm not sure if this semantic subtlety was important before.

@benjamn benjamn changed the base branch from master to release-2.5.0 January 22, 2019 23:39
@benjamn benjamn merged commit b37ef99 into release-2.5.0 Jan 22, 2019
@benjamn benjamn deleted the stop-QueryManager-more-thoroughly branch January 22, 2019 23:40
@benjamn benjamn added this to the Release 2.5.0 milestone Jan 22, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 1, 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.

1 participant