Skip to content
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

Selective Delayed Query Invalidation for Concurrent(large file upload) Mutations in RTK Query #4794

Open
pugsh opened this issue Dec 28, 2024 · 3 comments

Comments

@pugsh
Copy link

pugsh commented Dec 28, 2024

I was working on a file upload feature using RTK Query with automatic query invalidation. The feature refreshes the uploaded files list once a file upload is completed. However, when multiple files of varying sizes are uploaded simultaneously, an issue occurs. The upload API (mutation with a PUT call) and the list query use different tags. The list query invalidation waits for all mutation queries to complete, causing delays. Switching to immediate query invalidation is not feasible due to the risk of introducing stale data.

A mechanism for selective delayed query invalidation, targeting only the tags associated with pending queries, would help here.

Is this possible now?

@pugsh pugsh changed the title Delayed Query Invalidation Not Refetching Queries Due to Large File Upload in Progress Selective Delayed Query Invalidation for Concurrent(large file upload) Mutations in RTK Query Dec 28, 2024
@phryneas
Copy link
Member

No, there is currently no such feature.

A mechanism for selective delayed query invalidation, targeting only the tags associated with pending queries, would help here.

Unfortunately, this is also quite problematic - since tags can rely on the response of a mutation, we can't know them yet while the mutation is still in progress - and as a result, we also can't make this distinction beforehand.

@pugsh
Copy link
Author

pugsh commented Dec 30, 2024

Thanks @phryneas for responding. I understand the complexity here. There is one more case related to the upload, if any application is uploading a large file which takes good amount of time, it will block the automatic query invalidation for the whole app until the upload is complete.

Is it feasible to do some exception in such scenarios, delayed invalidation should not wait for some mutations or queries?

@phryneas
Copy link
Member

Right now, there's no such feature. Generally, I'd recommend to sidestep RTKQ for things like file uploads since you probably want to track upload progress manually anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants