Skip to content

fix(runtime-core): pause tracking when invoking function refs#14985

Open
edison1105 wants to merge 1 commit into
mainfrom
edison/fix/runtime-core-function-ref-tracking
Open

fix(runtime-core): pause tracking when invoking function refs#14985
edison1105 wants to merge 1 commit into
mainfrom
edison/fix/runtime-core-function-ref-tracking

Conversation

@edison1105

@edison1105 edison1105 commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Fixed function ref callbacks to prevent unintended re-invocation when reactive dependencies are accessed within the callback body.
  • Tests

    • Added test coverage for function ref callback tracking behavior.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 217c6596-34c3-46a0-8a63-e2e5b41a9b2d

📥 Commits

Reviewing files that changed from the base of the PR and between 325eb1d and c8140cc.

📒 Files selected for processing (2)
  • packages/runtime-core/__tests__/rendererTemplateRef.spec.ts
  • packages/runtime-core/src/rendererTemplateRef.ts

📝 Walkthrough

Walkthrough

rendererTemplateRef.ts imports pauseTracking and resetTracking from @vue/reactivity and wraps the function-ref invocation (callWithErrorHandling) in a pauseTracking/try-finally/resetTracking block. A new test verifies the callback is called once on mount and not re-invoked after a reactive dependency changes.

Function ref tracking suppression

Layer / File(s) Summary
Suppress tracking in function ref callbacks
packages/runtime-core/src/rendererTemplateRef.ts, packages/runtime-core/__tests__/rendererTemplateRef.spec.ts
Adds pauseTracking/resetTracking imports and wraps the callWithErrorHandling call for function refs in a try/finally block so callbacks cannot create reactive subscriptions. A new async test confirms the callback fires once on mount and not again after nextTick despite reading reactive state inside the callback.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Suggested labels

:hammer: p3-minor-bug

Poem

🐇 A ref once chased reactive deps with glee,
Re-running each tick — oh, unbounded was she!
But pauseTracking stepped in, calm and neat,
Wrapped the callback so tracking would sleep.
Now refs fire once, as all good refs should be! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: pausing tracking when invoking function refs in runtime-core, which is exactly what the implementation does.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch edison/fix/runtime-core-function-ref-tracking

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

@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 Jun 18, 2026
@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 106 kB (+24 B) 40.2 kB (+4 B) 36.1 kB (+19 B)
vue.global.prod.js 164 kB (+24 B) 60.2 kB (+3 B) 53.5 kB (+52 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.8 kB (+24 B) 19 kB (+10 B) 17.4 kB (+13 B)
createApp 56.9 kB (+24 B) 22 kB (+4 B) 20.1 kB (+4 B)
createSSRApp 61.2 kB (+24 B) 23.8 kB (+5 B) 21.7 kB (+8 B)
defineCustomElement 63.1 kB (+24 B) 23.9 kB (+3 B) 21.8 kB (+17 B)
overall 71.7 kB (+24 B) 27.4 kB (+5 B) 25 kB (+68 B)

@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: c8140cc

@edison1105

Copy link
Copy Markdown
Member Author

/ecosystem-ci run

@edison1105 edison1105 added the ready to merge The PR is ready to be merged. label Jun 18, 2026
@vue-bot

vue-bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

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

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. ready to merge The PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants