-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(vue-query): avoid use sync watchers that cause frequent requests #6043
fix(vue-query): avoid use sync watchers that cause frequent requests #6043
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit d750bd1. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit d750bd1:
|
Codecov ReportAll modified lines are covered by tests ✅ ❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
... and 9 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
@Mini-ghost could you get this to |
@DamianOsipiuk Sure! I will give it a try in the next few days. |
Linked issue
resolves #5996
Description
Starting from v4.34.3, there is an issue where the
queryFn
is erroneously triggered under the following conditions:enabled
property is set tofalse
, thequeryFn
should not be called, but the following code still triggers it:reproduce: https://stackblitz.com/edit/vitejs-vite-q1vdvf?file=src%2Fpages%2FPost.vue
queryKey
in the following way causes thequeryFn
to be called multiple times:reproduce: https://stackblitz.com/edit/vitejs-vite-j5dldg?file=src%2FApp.vue
The reason for this behavior is that when the
watch
configuration is set to{ flush: 'sync' }
, the watch callback is synchronously invoked every time there is a modification.You can find the relevant code in the source file here:
query/packages/vue-query/src/useBaseQuery.ts
Lines 109 to 116 in 22b2860
And this piece of code was introduced at that time to address this issue: #5910
So, this PR attempts to avoid using
{ flush: 'sync' }
and instead, it rewrapsrefetch
to ensure that theobserver
is correctly updated.