-
Notifications
You must be signed in to change notification settings - Fork 74
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
Race condition causes old "useSWRV" to set the isValidating of the new request (/ key). #345
Comments
I'm not sure I fully understand the issue you're reporting. Would you mind providing reproduction examples or steps and more details? |
SomeComponent.vue has a prop called id and has the following code in it: Now, if you change the id prop value passed to SomeComponent.vue while a fetch is active, it will trigger another fetch request (as expected) the problem is the isValidating of that new request will become false when the previous fetch call completes when it should obviously wait for the new call to complete (as these are different keys). If you look at #26 you'll notice they've added a check to see they are not updating the "IsValidating" of a previous call, but they haven't done so in the problematic line I was referring to: https://github.com/Kong/swrv/blob/master/src/use-swrv.ts#L280 |
Did you get a chance to look into it? @adamdehaven |
I think this could be resolved by utilizing dependent caching to invalidate the cache when the prop value changes. |
I believe this is related to #24
And is being caused by this line: https://github.com/Kong/swrv/blob/master/src/use-swrv.ts#L280
I would create a PR of removing this line, but the code is a bit complex and I'm not sure what else is influenced.
The text was updated successfully, but these errors were encountered: