-
-
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
polling polls one additional time after unsubscribe #1691
Comments
Hmm. To check, what you're saying is that you clicked and changed an argument, and then the previous poll went out? not that the arg change happened while the poll request was in flight? Just want to distinguish between "canceling a pending timer" and "canceling an in-flight HTTP request", which are completely different things. |
That's correct. Also like you said, it seems like it doesn't cancel the pending timer. To add a tad more info: getAll: build.query<PagedResource<ReservedWordResource>, ReservedWordsQueryParams | void>({
query: (params: ReservedWordsQueryParams) => {
console.log('params: ', params); // logs the query that shouldn't be sent
return {
url: '',
params: { ...baseParams, ...params }
};
},
providesTags: [cacheTags.reservedWords]
}), |
Yeah, all the timing behavior is done in the middleware. I suspect there's just no "cancel existing timer on arg change" logic in there. |
Is that something I should be adding, or should rtk do that out of the box? Updating my original example. Same issue without the facade, so cleaning it up a bit. |
Lenz would know more, but this sounds like a bug to me - just a use case that wasn't considered and handled. |
It sounds like a bug. We already had a report of this before if I remember correctly, but the author didn't come around to provide a reproduction yet. I'll add it to the list - but it might take some time. |
Thanks @phryneas . Do you need me to create a small project with a repro? I wouldn't be familiar with React enough to use rtk-query out of the box, but I could put something together with code very similar to what I have above. |
@phryneas is there an update on this issue? I experience the same issue with React 17.0.2 and @reduxjs/toolkit: 1.6.2 |
No, this is still open. PRs are welcome, but I have too much going on in real life to get to this at the moment, sorry. |
@phryneas any workaround? |
I would have said so if I knew about one. As I said, PRs are welcome. |
@phryneas PR submitted. If I understand correctly, Here's a screenshot from putting a watch on it in vscode with At this point, the args have been updated to request I'll continue the conversation related to my PR in the PR comments. |
Fixed by #1933. Thank you so much @msutkowski !! |
` import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; export const productsApi = createApi({ export const {
its not working for me |
Full Disclosure: I'm using ngrx-rtk-query with Angular. It might be their problem.
Environment
Summary
I have an endpoint that takes paging params, e.g.,
{pageNumber: number, pageSize: number}
. I refetch the data every 30 seconds to ensure the latest data is visible to the user.rtk-query will send the last request of any query that didn't send prior to the arg change.
For example, if a user is on page 1, then goes to page 2, the following requests will be sent in this order:
Here's the relevant code
The text was updated successfully, but these errors were encountered: