metadata: fix DataCloneError when opening metadata dialog after filter click#705
Merged
ajslater merged 2 commits intov1.11-performancefrom May 3, 2026
Merged
Conversation
The previous implementation cloned ``{ ...rawSettings, filters }`` via
``structuredClone`` purely so it could ``delete data.mtime`` without
mutating the caller's settings. But the filter payload comes straight
from the Pinia browser store, which keeps the inner ``filters[k]``
arrays as Vue reactive Proxies. ``toRaw`` only unwraps one level, so
those proxied arrays survived into ``structuredClone`` — which refuses
to clone certain Vue proxies, surfacing as
``DataCloneError: [object Array] could not be cloned`` whenever a user
clicked a Genre / Author / etc. chip in the metadata dialog.
The clone was redundant in any case: ``serializeParams`` (the only
consumer of ``data``) already deep-clones via ``_deepClone``, which
calls ``toRaw`` at every level. Replace the clone-then-delete dance
with a destructure that strips ``mtime`` cleanly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The ``getMetadata`` ``DataCloneError`` fix landed earlier in this PR
applied to one site; the same anti-pattern lived in five other places.
Each one cloned a Vue reactive value (Pinia store row, breadcrumb,
route params) via ``structuredClone(toRaw(x))`` — the outer ``toRaw``
unwraps only one level, so a nested reactive Array proxy can still
trip ``DataCloneError: [object Array] could not be cloned``.
Two cleanup categories:
* **Destructure-and-drop** (breadcrumbs, reader close button) —
the clone existed only to ``delete params.name``. Replaced with
``const { name: _name, ...params } = toRaw(crumb)``: no clone,
no proxy hazard.
* **Genuine deep copy** (admin create/update dialog + its mixin) —
promoted the existing private ``_deepClone`` in ``api/v3/common.js``
to an exported ``deepClone``. It already does what these sites
need: recursive ``toRaw`` at every level, no structuredClone
fragility. Swapped four ``structuredClone(toRaw(x))`` calls for
``deepClone(x)``.
Also dropped one defensive clone entirely
(``reader-book-change-nav-button.vue``): vue-router snapshots
``params`` itself, so the outer clone was never load-bearing.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
structuredClonecall ingetMetadatathat was throwingDataCloneError: [object Array] could not be clonedwhen the metadata dialog opened after the user clicked a Genre / Author / etc. chip.delete data.mtimewithout mutating the caller's settings; replaced with a destructure that stripsmtimecleanly.Why
getMetadatais fed byuseBrowserStore().metadataSettings, which reuses the innerstate.settings.filters[k]arrays from the Pinia store. Those arrays are Vue reactive Proxies, andtoRawonly unwraps one level — so the proxied arrays survived intostructuredClone, which refuses to clone them.The clone was also redundant:
serializeParams(the only consumer ofdatahere) already deep-clones via_deepClone, which recursively callstoRaw. So dropping the structured clone is both a fix and a small simplification.Reproduces with the stack trace the user reported:
Test plan
npx eslint src/api/v3/browser.js— cleannpx prettier --check src/api/v3/browser.js— cleanbun run test:ci— 1/1 passed🤖 Generated with Claude Code