Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Persistence corrupts the stores on refresh (for stores in option.paths) #5

Open
joerattz opened this issue Jun 8, 2022 · 0 comments

Comments

@joerattz
Copy link

joerattz commented Jun 8, 2022

When rehydrating/merging the persisted data for the stores it is corrupting the local storage and store. I have 3 stores named common, crm-dashboard, and deal. We are configured to only persist common and deal.stages.

Here's my config:

  store.use(
    persistedstate({
      overwrite: true,
      paths: ['common', 'deal.stages']
    })
  )
  1. I'll delete Pinia from the browser local storage. Here's local storage after deleting it.

image

  1. I'll do a CTRL+F5 to force a full refresh.

We now have a legit local storage for Pinia.

image

That all looks correct. It contains only the things we've configured (via option.paths) to persist.

Likewise, the Pinia store looks correct using the Chrome Vue extension.

Here's the deal store state, which is correct.

image

Here's the common store state, which is correct.

image

  1. Now I'll do an F5 to refresh.

The first indication of trouble is that local storage is now corrupted. Notice that nested in the common store are the common and deal stores!

image

And so too are the deal and common stores.

image

image

I'm using version 0.1.2 of pinia-persistedstate.

$ npm list pinia-persistedstate

deals-client@1.0.0 C:\development\CRMDealsWebApp
`-- pinia-persistedstate@0.1.2
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant