Skip to content

fix(reactivity): preserve updates with repeated dependencies (fix #16174) - #16178

Open
Narek-Khachikyan wants to merge 2 commits into
vuejs:minorfrom
Narek-Khachikyan:fix/computed-repeated-dependency-16174
Open

Narek-Khachikyan wants to merge 2 commits into
vuejs:minorfrom
Narek-Khachikyan:fix/computed-repeated-dependency-16174

Conversation

@Narek-Khachikyan

Copy link
Copy Markdown

When a computed reads the same dependency non-adjacently, duplicate links can consume its recursion state twice during one push. An effect that writes a dependency of the computed it reads can then miss a later update: the reproduction produces [1, 4] instead of [1, 4, 0].

Record successful propagation transitions per invocation before callback-capable flag writes. This preserves legal duplicate links while preventing repeated state advancement, including after newer nested pushes. A clean subscriber still receives an invalidation from a dirty or pending dependency that the nested push did not cover.

Targets minor: the affected 3.6 reactivity implementation differs from stable 3.5.

Closes #16174

Evidence

  • Exact reproduction fails on the base and passes here. Regressions cover separated reads, cleanup, nested notification order, and uncovered computed branches; 156 focused tests pass.
  • CI=true pnpm test-unit --maxWorkers=2: 288 files pass; 9328 passed, 2 expected fail, 3 skipped, 17 todo. Explicit GC: 4 passed, 2 existing todo, no skips.
  • Typecheck, lint, formatting, and diff checks pass.

Trade-offs

Extra propagation bookkeeping adds 165 raw / 49 gzip bytes to the production reactivity esm-browser build. A historical 35% sequential large-ref throughput loss did not consistently reproduce under paired comparisons; a few-percent cost remains uncertain on the shared host. The unchanged default 30 ms computed timing guard passed in the final focused run; an earlier loaded run failed at about 300 ms.

Track successful propagation generations so repeated dependency links do
not consume Recursed state twice within the same push. Preserve newer
nested notifications when an older traversal resumes after onTrigger.

Cover the lost-update reproduction, longer read gaps, conditional cleanup
and nested notification order without changing dependency tracking.

Closes vuejs#16174
Allow an older traversal to invalidate a clean subscriber when its incoming dependency is still dirty or pending. A newer nested notification cannot cover a computed branch that has not yet been invalidated. Keep generation-based suppression for duplicate links whose dependencies have already been read clean.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8b4245eb-3f5d-4844-80d7-c25edfcedd69

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
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 this pull request may close these issues.

1 participant