-
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
useLazyQuery
calls for the same endpoint in quick succession results in at least one of the requests being canceled
#10717
Comments
Hey @rodericktech 👋 Apologies this is happening with the latest update. I recently fixed several bugs where 1) multiple calls to execution function in a row would resolve with data from the last execution rather than the request it kicked off and 2) would ensure the promise isn't stuck pending indefinitely when a component unmounts. It's odd to me that you're seeing any kind of cancellation given that I removed the abort related code between I totally understand about the NDA issue. That said, I could really use some more information to understand what is happening here, as I'm not sure I have enough to go on to be able to reproduce the issue. I'm hoping you can provide me with some code samples with obscured names/details and/or more information to understand the conditions under which this issue is happening. Some information that would be helpful:
Alternatively, if you are able to write me a failing test, this would go a long way to helping me out. We shouldn't need your schema or your query names to recreate the issue. Trying to distill down the relevant info (same query name, different vars, etc) can be extremely helpful to narrow this down. Thanks! |
Thank you for your prompt reply @jerelmiller ! I do not know how soon I can make time to try to create an approximation of the code situation or a failing test but in the meantime I will do my best to answer your questions.
The query looks something like this:
It is called with
The function in the hook ( |
Thanks so much @rodericktech! The code samples help a ton. Just to make sure I'm understanding whats being called here, are you calling your wrapped function twice in succession, or are you calling If the wrapped function, are you running those in parallel or // in parallel
const [result1, result2] = await Promise.all([
listTheseThings(...),
listTheseThings(...)
]);
// or awaiting one then kicking off the other?
const result1 = await listTheseThings(...);
const result2 = await listTheseThings(...); Just want to make sure I can accurately try and reproduce this as much as possible. Thanks! |
You're welcome! In my case, I'm calling the wrapped function twice in succession, along the lines of the latter of your two examples - awaiting the result of the first and then starting the second shortly afterward. |
Awesome thank you! I'll try and setup a toy app that tries to reproduce this and see if I can get the same result. |
fwiw we are seeing the same behavior. Reverting to |
It actually looks like updating to the latest Apollo Client makes the issue go away, although it's hard to be sure because the issue is intermittent. |
I have tried In versions |
@rodericktech would you be able to revert to Apologies I haven't had time to get back to this! Its on my list of things to come back to as soon as I'm finished up with some of my current commits. |
@jerelmiller No problem - I understand the kinds of constraints involved in managing a project like this. I will try 3.7.3 and see if that is a workable temporary solution - thank you. |
Just an update to say I've kept our project on |
Hey @rodericktech, I know its been a while since you opened this issue and I'm sorry its taken me this long to get back to you. We just released a fix in Reading back through this thread, I suspect the cancelled request might be because of this weird duplicate request situation where we inadvertently sent the same request when calling Would you mind trying |
Thank you for getting back to me @jerelmiller - I will try |
Hello again - thus far in my testing with |
@rodericktech thats wonderful news! As such, I'll go ahead and close this issue 🙂 If you wanted to be absolutely sure, downgrading to 3.9.3 should reproduce the issue (no need to do that unless you're bored 🤣) Thanks for all the patience on this one! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Issue Description
Beginning with
3.7.11
, I am now seeing a behavior in our React front end on a complex page where calls to the same endpoint in succession (with different parameters / variables) result in at least one of the queries being canceled (along with other strange behavior).I do not know how to put enough code together to provide a guaranteed working example close to my situation as the use case is rather complicated and I have only seen the breakage in one place in the front end so far. (And the code I'm writing / company this is for has everything under NDA, so the project cannot be shared directly or pointed at.)
To summarize the behavior: a page that is loading related data sets, looking at the data from multiple 'angles' (and so using multiple queries), has two Apollo queries in succession with the same name / same endpoint in the underlying API. One of the queries is designed to retrieve detailed information about a single entity; the second is run to make a shallow list of identifying information for all the similar entities in that 'stack'. (This is for performance reasons, as the query returning more detailed data is much slower for the entities in question.)
Both of these operations run
useLazyQuery
under the hood with the same-named query (call itquery ListTheseThings() ...
), just passing in different variables. The first query appears to run, but when the second (shallow) query is attempted, app execution dies immediately even though a response to that query does show in dev tools; the first query then appears to be 'canceled'. (According to the network tab.)Both queries pass 'no-cache' so caching is not involved.
After reverting to
3.7.10
the queries both execute as expected and the page render completes normally.Link to Reproduction
https://www.cant-create-a-repro-for-this.test/im-sorry
Reproduction Steps
No response
The text was updated successfully, but these errors were encountered: