-
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
[v3.4rc19] Query ancellation appears broken in 3.4 #8496
Comments
@sebastienbarre Can you tell which beta/RC version introduced the regression? Was it |
@benjamn Indeed rc19. I'm trying to hunt down the reproduction repo that was used the last time cancellation was broken, see if it can show the same issue. Thx. |
That was #4955 back then, but now that I re-read it, it was cancelling not working when a component was unmounted, so it's a different case it seems. |
@benjamn Do you guys have a reproduction repo that performs actual network requests, client<->server? |
@sebastienbarre You can return a cleanup function from an Observable, which would allow you to log request cancellations. See here for the Observable API const link = new ApolloLink(operation => {
- return new Observable(async observer => {
+ return new Observable(observer => {
const { query, operationName, variables } = operation;
- await delay(300);
+ let completed = false;
+ delay(300).then(async () => {
try {
const result = await graphql(
schema,
print(query),
null,
null,
variables,
operationName,
);
+ completed = true;
observer.next(result);
observer.complete();
} catch (err) {
+ completed = true;
observer.error(err);
}
+ });
+ return () => {
+ console.log(completed ? 'request completed!' : 'request cancelled!', operationName, variables.searchTerm);
+ };
});
}); |
I've just un-installed "3.4.0-rc.6" and installed "3.4.0-rc.18" to see if it helps with the problems I've been having but a useLazyQuery which has "fetchPolicy" of "network-only" and "nextFetchPolicy" of "cache-first" now gets cancelled and another IS NOT triggered. My problem is #8514 (actually two problems). |
@sebastienbarre Can you check 3.4.5? That might have fixed this. |
@brainkim I tried with 3.4.4, it was still broken. I just tried with 3.4.5, and that indeed fixed it, thanks :) |
@apollo/client Issues here surrounding cancelation which may be resolved with: apollographql/apollo-client#8496 @ember/test-waiters Fixes an issue with embroider build: ember-graphql#404
Intended outcome:
Previous GraphQL query is cancelled automatically when repeated.
Actual outcome:
Previous GraphQL query is cancelled... but new one is not triggered.
How to reproduce the issue:
I'll try to get a repo up and running, but I wanted to mention it quick, since it seems we are getting close to the official 3.4.
Essentially I have a classic, debounced "search" input field, where our user will type a few letters and the UI will perform a search query every X milliseconds once the field has debounced. This used to work nicely in 3.3; if a GraphQL query was still in flight by the time the UI next debounced, the new query would cancel the old one before the new one would take over.
See Network tab below, where 2 queries were cancelled, and the last one succeeded (since the user stopped typing):
This is no longer the case for me in 3.4rc19, the old one is cancelled... but the new one never goes through. See below, the old one is cancelled, but no new one in sight.
Versions
The text was updated successfully, but these errors were encountered: