You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a slight issue with invalidating initial running requests using tags. Some of our GET requests take a couple of seconds to finish, some even 10 seconds (yeah, it is what it is). During the fetching process the user is allowed to do mutations on the same underlying table, causing tags for that table to be invalidated. However, no tags are provided yet as they are provided only after the GET request is finished. So there's no way for us to invalidate that initial long request while still running.
It would help if we can pre-provide certain tags to our endpoint, which we can use to invalidate requests that are not fully loaded yet. But as far as I can see, there's no such thing. We have a couple of workarounds in mind, like invalidating endpoints by providing an extra data version number in the endpoint argument. Before we go the workaround route, are there any tips to handle this situation?
Thanks, and thanks for the amazing library (RTK + query). Works great!
The text was updated successfully, but these errors were encountered:
That would probably not help you. invalidateTags starts new queries for all impacted queries, you are right on that.
But in RTK-Q, if a query is already running, a new query won't be started. So even if you would invalidate that, it would not cause a new request while the old one was already running.
Without really knowing our application I'm also out of ideas on a good solution for you there, I'm sorry.
So invalidation doesn't work for running queries at all. That's something I didn't expect, but was on my list to check later on. It's essential that it works for us, although long running queries are rare. So I'm looking for workarounds here.
Just out of my head, isn't it something we can fix by first aborting all the affected running queries, and then invalidate? Like so:
consttags=['Post']constinvalidatedBy=selectInvalidatedBy(getState(),tags);// Find and abort the operation promise for each query corresponding to given tagsinvalidatedBy.forEach(({ endpointName, originalArgs })=>{constoperationPromise=api.util.getRunningOperationPromise(endpointName,originalArgs)operationPromise.abort()})dispatch(api.util.invalidateTags(tags))
Still not a fix for the initial running queries though
We have a slight issue with invalidating initial running requests using tags. Some of our GET requests take a couple of seconds to finish, some even 10 seconds (yeah, it is what it is). During the fetching process the user is allowed to do mutations on the same underlying table, causing tags for that table to be invalidated. However, no tags are provided yet as they are provided only after the GET request is finished. So there's no way for us to invalidate that initial long request while still running.
It would help if we can pre-provide certain tags to our endpoint, which we can use to invalidate requests that are not fully loaded yet. But as far as I can see, there's no such thing. We have a couple of workarounds in mind, like invalidating endpoints by providing an extra data version number in the endpoint argument. Before we go the workaround route, are there any tips to handle this situation?
Thanks, and thanks for the amazing library (RTK + query). Works great!
The text was updated successfully, but these errors were encountered: