question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOMException: Failed to execute 'replaceState' on 'History': #<Object> could not be cloned

See original GitHub issue

Versions:

  • @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:open
  • Created 2 years ago
  • Reactions:5
  • Comments:43 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
coclavcommented, Feb 24, 2022

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.

image

So I had to find out what couldn’t be cloned ?!

image

put a breakpoint there… and started to dig into the e object until i saw this

image

I tried to “unProxy” the value with JSON.parse(JSON.stringify(formField)), and this solved the issue.

6reactions
ewhichercommented, Jun 7, 2022

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 the JSON.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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found