Skip to content

fix(kit): only treat ancestors as circular references - #1179

Merged
webfansplz merged 1 commit into
vuejs:mainfrom
NgoQuocViet2001:fix-codec-shared-references
Oct 26, 2026
Merged

webfansplz merged 1 commit into
vuejs:mainfrom
NgoQuocViet2001:fix-codec-shared-references

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor

encodeValue adds every visited object to seen and never removes it, so an object that appears a second time in the same value is encoded as { kind: 'circular' } even when there is no cycle. With the default budget, a component returning range: ref({ start: today, end: today }) and rows: ref(Array(2).fill(row)) shows end and rows[1] as [Circular value:N]. Expanding the row loads the real value, but copied text and agent output only show the marker.

This removes an object from seen once its subtree is done, so only ancestors on the current path count as circular. To keep the work bounded by the number of distinct objects as before, a repeated non-ancestor is encoded without children, like a value at the depth limit: it keeps its kind, size and handle, and the client loads its fields on expand. Dates, RegExps and Errors are still encoded in full. With the default budget (lazy children at depth 1, which the Vite plugin and Chrome extension use), repeated values now encode the same as non-shared ones.

  • Ran: vitest run tests/unit/codec/encode-value.test.ts. On main the new test fails with expected { kind: 'circular', handle: 'value:2' } to deeply equal { Object (kind, name, ...) }; with the change 15/15 pass.
  • Ran: vitest run: 70 files, 431 tests pass (main: 70 files, 429 tests).
  • Ran: vp fmt --check and vp lint (type-aware) on both changed files, and tsc --noEmit -p packages/kit/tsconfig.json: no issues.
  • Checked: components:stateSnapshot for the component above returns range: start:date, end:date and rows: 0:object, 1:object (main: end:circular, 1:circular).
  • Checked: a 20-level chain of { l: next, r: next } encoded with maxDepth: 21 stays at about 4 KB (main: 3 KB), so shared subtrees are not walked once per path.

@netlify

netlify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-devtools-docs canceled.

Name Link
🔨 Latest commit af33727
🔍 Latest deploy log https://app.netlify.com/projects/vue-devtools-docs/deploys/6add01c24d15c298a09cc1a8

@pkg-pr-new

pkg-pr-new Bot commented Oct 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@vue/devtools-agent@1179
npm i https://pkg.pr.new/@vue/devtools-api@1179
npm i https://pkg.pr.new/@vue/devtools-kit@1179
npm i https://pkg.pr.new/vite-plugin-vue-devtools@1179

commit: af33727

@webfansplz webfansplz changed the title fix(codec): only treat ancestors as circular references fix(kit): only treat ancestors as circular references Oct 26, 2026
@webfansplz
webfansplz merged commit 6ec530b into vuejs:main Oct 26, 2026
7 checks passed
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.

2 participants