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

Sometimes vue-query doesn't respect enabled #5996

Closed
Mini-ghost opened this issue Sep 12, 2023 · 0 comments · Fixed by #6043
Closed

Sometimes vue-query doesn't respect enabled #5996

Mini-ghost opened this issue Sep 12, 2023 · 0 comments · Fixed by #6043

Comments

@Mini-ghost
Copy link
Contributor

Mini-ghost commented Sep 12, 2023

Describe the bug

Sometimes vue-query doesn't respect enabled, It happens when enabled changes from true to false

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-q1vdvf?file=src%2Fpages%2FPost.vue

Steps to reproduce

  1. Go to reproducible
  2. Click the link with content 1, and queryFn will be executed.
  3. Click the link with content 20, and queryFn will be executed.

According to the enabled condition, when postId is greater than 10, it will be false

const enabled = computed(() => {
  return !!postId.value.id && postId.value.id < 10;
});

Expected behavior

queryFn should not be called when enabled is false

How often does this bug happen?

Sometimes

Screenshots or Videos

No response

Platform

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 90.47 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
  Browsers:
    Firefox: 116.0.2
    Safari: 14.1.2
    Safari Technology Preview: 15.4
  npmPackages:
    vue: ^3.3.4 => 3.3.4 

Tanstack Query adapter

None

TanStack Query version

v4.34.3

TypeScript version

v5.2.2

Additional context

I guess it is because { flush:'sync' } caused the current issue. The following are relevant references.

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

Successfully merging a pull request may close this issue.

1 participant