DOMException: Failed to execute 'replaceState' on 'History': #<Object> could not be cloned
See original GitHub issueVersions:
@inertiajs/inertia
version: 0.9.2@inertiajs/inertia-vue3
version: 0.4.7
Describe the problem:
I am using Vue 3 Draggable package. In the event of dragging an element, I execute Inertia.put method and pass some data to Laravel. This is where this exception occurs.
Steps to reproduce:
For example, in Laravel pass a project with a list of columns to your view. Then use the Draggable component as following:
<Draggable
v-model="project.columns"
group="columns"
item-key="id"
@end="onColumnPositionChanged"
>
<template #item="{element: column}">
<KanbanColumn
:column="column"
:key="column.id"
/>
</template>
</Draggable>
In event of onColumnPositionChanged, trigger Inertia.put method
const onCardPositionChanged = () => {
Inertia.put('/some-route');
};
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:43 (7 by maintainers)
Top Results From Across the Web
Failed to execute 'replaceState' on 'History': #<Object> could ...
In every navigation link, the error Uncaught DOMException: Failed to execute 'replaceState' on 'History': #<Object> could not be cloned. is ...
Read more >Inertia and Sortable.js (VueDraggable) - Laracasts
Uncaught DOMException: Failed to execute 'replaceState' on 'History': #<Object> could not be cloned. at e.n.replaceState (webpack-internal:///.
Read more >Uncaught DOMException: Failed to execute 'replaceState' on ...
"Uncaught DOMException: Failed to execute 'replaceState' on 'History': A history state object" is appears after going to Dashboards page.
Read more >T283828 DataCloneError: Failed to execute 'pushState' on ...
DataCloneError : Failed to execute 'pushState' on 'History': HTMLLIElement object could not be cloned. trace. at Object.changeUrl URL1:98:850 at Object.
Read more >Uncaught DOMException: Failed to execute 'pushState' on ...
replaceState or history.pushState . For example try: history.pushState({node: document.body}, 'title', '#/error') or use ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I pulled my hair on this one for months. My solution was similar to this https://github.com/inertiajs/inertia/issues/775#issuecomment-876030983 above
Spoiler : the problem was because a “Proxy” made its way to my state.
So I had to find out what couldn’t be cloned ?!
put a breakpoint there… and started to dig into the
e
object until i saw thisI tried to “unProxy” the value with
JSON.parse(JSON.stringify(formField)),
and this solved the issue.I’m just going to pop this on here: https://web.dev/structured-clone/
It digs in to the new
structuredClone()
api and lists some of the shortcomings of theJSON.parse(JSON.stringify())
approach.For anyone running into issues it might turn out to be a better option, or you might find you need a library like Lodash.
Hopefully this is helpful to anyone who has scrolled this far with no success!