Skip to content

fix(reactivity): avoid duplicate raw/proxy entries in Set.add#14545

Merged
edison1105 merged 1 commit intomainfrom
edison/fix/reactivitySet
Mar 9, 2026
Merged

fix(reactivity): avoid duplicate raw/proxy entries in Set.add#14545
edison1105 merged 1 commit intomainfrom
edison/fix/reactivitySet

Conversation

@edison1105
Copy link
Copy Markdown
Member

@edison1105 edison1105 commented Mar 9, 2026

Summary by CodeRabbit

Release Notes

  • Tests

    • Added comprehensive tests for Set behavior when working with readonly and shallow reactive values, ensuring duplicate prevention and accurate raw value tracking.
  • Bug Fixes

    • Improved Set and WeakSet value addition logic to properly handle raw values and prevent duplicates when mixing reactive and readonly wrappers with set operations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1594fd35-89f0-4745-8832-5aea8ef7fb44

📥 Commits

Reviewing files that changed from the base of the PR and between 5dc27ca and f210145.

📒 Files selected for processing (2)
  • packages/reactivity/__tests__/collections/Set.spec.ts
  • packages/reactivity/src/collectionHandlers.ts

📝 Walkthrough

Walkthrough

This change adds test coverage for Set behavior with readonly and reactive-wrapped values, and modifies the Set add logic in collectionHandlers.ts to properly handle raw value comparisons when determining duplicates and key existence, ensuring that mixed reactive and readonly values don't create unintended duplicates.

Changes

Cohort / File(s) Summary
Set Tests
packages/reactivity/__tests__/collections/Set.spec.ts
Adds two new test cases verifying that readonly-wrapped and proxy-wrapped raw values don't create duplicates when added to reactive Sets, and that toRaw(set) reflects only original raw values.
Set Add Logic
packages/reactivity/src/collectionHandlers.ts
Modifies the Set/WeakSet add operation to precompute rawValue and use it for determining valueToAdd and hadKey checks, improving handling of mixed reactive/readonly values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

scope: reactivity, ready to merge

Poem

🐰 A Set once doubled with reactive care,
But raw values helped us see the snare,
With readonly wrapped and shallow made true,
The fuzzy logic now rings clear and new! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix(reactivity): avoid duplicate raw/proxy entries in Set.add' clearly and specifically describes the main change—preventing duplicate entries when both raw and proxy values are added to a Set.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch edison/fix/reactivitySet

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 9, 2026

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 104 kB (+30 B) 39.4 kB (+11 B) 35.5 kB (-26 B)
vue.global.prod.js 162 kB (+30 B) 59.4 kB (+11 B) 52.9 kB (+61 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.1 kB (+48 B) 18.7 kB (+11 B) 17.1 kB (+13 B)
createApp 56.2 kB (+48 B) 21.7 kB (+10 B) 19.9 kB (+13 B)
createSSRApp 60.5 kB (+48 B) 23.5 kB (+11 B) 21.4 kB (+8 B)
defineCustomElement 61.9 kB (+48 B) 23.5 kB (+11 B) 21.4 kB (+8 B)
overall 70.6 kB (+48 B) 27 kB (+12 B) 24.6 kB (-2 B)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 9, 2026

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14545
npm i https://pkg.pr.new/@vue/compiler-core@14545
yarn add https://pkg.pr.new/@vue/compiler-core@14545.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14545
npm i https://pkg.pr.new/@vue/compiler-dom@14545
yarn add https://pkg.pr.new/@vue/compiler-dom@14545.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14545
npm i https://pkg.pr.new/@vue/compiler-sfc@14545
yarn add https://pkg.pr.new/@vue/compiler-sfc@14545.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14545
npm i https://pkg.pr.new/@vue/compiler-ssr@14545
yarn add https://pkg.pr.new/@vue/compiler-ssr@14545.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14545
npm i https://pkg.pr.new/@vue/reactivity@14545
yarn add https://pkg.pr.new/@vue/reactivity@14545.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14545
npm i https://pkg.pr.new/@vue/runtime-core@14545
yarn add https://pkg.pr.new/@vue/runtime-core@14545.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14545
npm i https://pkg.pr.new/@vue/runtime-dom@14545
yarn add https://pkg.pr.new/@vue/runtime-dom@14545.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14545
npm i https://pkg.pr.new/@vue/server-renderer@14545
yarn add https://pkg.pr.new/@vue/server-renderer@14545.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14545
npm i https://pkg.pr.new/@vue/shared@14545
yarn add https://pkg.pr.new/@vue/shared@14545.tgz

vue

pnpm add https://pkg.pr.new/vue@14545
npm i https://pkg.pr.new/vue@14545
yarn add https://pkg.pr.new/vue@14545.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14545
npm i https://pkg.pr.new/@vue/compat@14545
yarn add https://pkg.pr.new/@vue/compat@14545.tgz

commit: e106fd4

@edison1105
Copy link
Copy Markdown
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Copy Markdown
Contributor

vue-bot commented Mar 9, 2026

📝 Ran ecosystem CI: Open

suite result latest scheduled
nuxt success success
quasar success success
pinia success success
router success success
vite-plugin-vue success success
radix-vue success success
vuetify success success
vueuse success success
vitepress success success
primevue success success
test-utils success success
vue-i18n success success
language-tools failure failure
vant failure success
vue-macros success success
vue-simple-compiler success success

@edison1105 edison1105 merged commit d943612 into main Mar 9, 2026
15 of 16 checks passed
@edison1105 edison1105 deleted the edison/fix/reactivitySet branch March 9, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants