Skip to content

pushState() throw DevalueError: Cannot stringify POJOs with symbolic keys #11363

Description

@dangelomedinag

Describe the bug

const result= preloadData(url) result.data --> returns POJO
when you use pushState(url, {key: result.data}) for the second time result.data has a Symbol($state) and cannot be serialized

This happens when using pushState or replaceState, if you don't use any result.data it always returns a POJO

Reproduction

reproduction

// routes/subroute.js
export const load = () => {
  return {
    user: {
      number:123,
      name: "string"
    }
  }
}
<!-- routes/+page.svelte -->
<script>
  import {pushState, preloadData} from "$app/navigation"
  function getData(){
    const result = preloadData("/subroute")
    console.log(result.data)  
    // first time {user: {…}}
    // second time {user: {…}, Symbol($state): {…}}
    if (result.type === "loaded" && result.type === 200) {
      pushState("/subroute", {key: result.data}) // second time --> DevalueError: Cannot stringify POJOs with symbolic keys
    }
  }
</script>
<button onclick={getData}>click two times</button>

error

Logs

No response

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/adapter-auto: ^3.0.0 => 3.0.0 
    @sveltejs/kit: ^2.0.0 => 2.0.0 
    @sveltejs/vite-plugin-svelte: ^3.0.0 => 3.0.1 
    svelte: ^5.0.0-next.25 => 5.0.0-next.25 
    vite: ^5.0.0 => 5.0.10

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions