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

warnRecursiveComputed no longer works #12845

Open
thecodewarrior opened this issue Feb 10, 2025 · 1 comment · May be fixed by #12225
Open

warnRecursiveComputed no longer works #12845

thecodewarrior opened this issue Feb 10, 2025 · 1 comment · May be fixed by #12225
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.

Comments

@thecodewarrior
Copy link

Vue version

3.5.13

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-exn7drue?file=src%2FApp.vue

Steps to reproduce

  1. Set the app.config.warnRecursiveComputed flag to true
  2. Create a computed that mutates its dependencies
  3. Use that computed in the template

What is expected?

Vue should log a warning because the computed is still dirty after being evaluated

What is actually happening?

No warning is logged

System Info

Any additional comments?

The warning is mentioned in #10341, and the config option is added in 23953dd.

It seems that much of the code for computed refs was moved into a separate function, refreshComputed, at which point the functionality was lost.

I got a minimal patch working by duplicating the initial dirty check into the finally block after cleanupDeps, though I'm not certain if that's the right place for it:

    activeSub = prevSub
    shouldTrack = prevShouldTrack
    cleanupDeps(computed)

    if (
      computed._warnRecursive &&
      !computed.isSSR &&
      computed.deps &&
      isDirty(computed)
    ) {
      console.warn("O no", computed.fn)
    }

    computed.flags &= ~EffectFlags.RUNNING

In an ideal scenario the warning would be able to specify exactly which dependencies caused the computed to be dirty, but that might be too complex.

@edison1105
Copy link
Member

will be fixed via #12225

@edison1105 edison1105 linked a pull request Feb 11, 2025 that will close this issue
@edison1105 edison1105 added the 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants