Skip to content

warnRecursiveComputed no longer works #12845

Closed
@thecodewarrior

Description

@thecodewarrior

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions