-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
BUG: UseLazyXXXQuery Returning undefined On Long Running Queries #3706
Comments
After diving into the code, I realized that the useLazyQuery and useLazyQuerySubscription hooks only maintain a single promise; they are not re-entrant! I created the following useReEntrantLazyQuerySubscription hook - closely mimicking the official code - as a work-around. Now all of my requests are properly resolving no matter how many are kicked off concurrently, nor if they all take several minutes to resolve:
This might be a good hook to add to the repository + document the re-entrant behavior of the useLazyQuery and useLazyQuerySubscription hooks. This one doesn't maintain the lastArgs, but that wouldn't really make sense anyways if you are submitting simultaneous requests. |
Interesting. I think a full-on solution might need a change in |
Can you try the latest CodeSandbox CSB build from #3089 and see if this is resolved? |
I'm going to assume that this is fixed by #3709 , and that fix is available in https://github.com/reduxjs/redux-toolkit/releases/tag/v2.0.0-beta.4 . Please let us know if there's further issues! |
I am in the process of optimizing my website to handle efficiently querying from tables with potentially hundreds of millions of records, and for those queries that are presently not optimized I have noticed the occasional odd error from RTK Query. In particular, I have noticed that when the queries start taking minutes to resolve (and they eventually do resolve successfully) that sometimes RTK Query returns undefined from the promise. IE...
When the error occurs, here is the log trace:
NOTE: I have confirmed that the requests do resolve properly (with the expected data) by monitoring the requests via the Network tab in the Developer Tools on Firefox. Also, there are usually several similar requests being sent at once (via the 3rd party component AgGrid), but with different arguments. Some resolve successfully, others are resolving prematurely and getting the above error.
EDIT: I removed the unwrap statement and added some more trace
EDIT 2: Possibly the same bug as #3662
The text was updated successfully, but these errors were encountered: