Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Uncaught Error: [Vuex Electron] Storage is not valid. Please, read the docs. #38

Open
mxj7000 opened this issue Apr 29, 2019 · 7 comments

Comments

@mxj7000
Copy link

mxj7000 commented Apr 29, 2019

Hi, Integrate the vuex into the electron , my application will run to this issues,

Uncaught Error: [Vuex Electron] Storage is not valid. Please, read the docs.
at a (C:\Users\Administrator\Desktop\win-unpacked\resources\app.asar\node_modules\vuex-electron\dist\persisted-state.js:1)
at C:\Users\Administrator\Desktop\win-unpacked\resources\app.asar\node_modules\vuex-electron\dist\persisted-state.js:1
at C:\Users\Administrator\Desktop\win-unpacked\resources\app.asar\node_modules\vuex\dist\vuex.common.js:345
at Array.forEach ()
at new Store (C:\Users\Administrator\Desktop\win-unpacked\resources\app.asar\node_modules\vuex\dist\vuex.common.js:345)
at Object. (renderer.js:1)
at d (renderer.js:1)
at n (renderer.js:1)
at Object. (renderer.js:1)
at d (renderer.js:1)

Who knows going on with this? I confusion with this problem about on week;

@mxj7000
Copy link
Author

mxj7000 commented May 11, 2019

Resolved issues, we don't use the vuex-electron to do it;

@akodkod
Copy link
Contributor

akodkod commented Aug 29, 2019

#44

@zjruan
Copy link

zjruan commented Nov 7, 2019

vuex-electron‘s createPersistedState method , depend electron-store <- conf <- write-file-atomic. and the method writeFileSync in write-file-atomic use fs.renameSync.

But, fs.renameSync Sometimes it goes wrong when multithreading because race condition。and every electron window is a rendering process。So,there is no solution until write-file-atomic solves the problem.

We can find that the root cause of the problem is multithreading, so here's an idea. We can also rewrite createPersistedState method to store data locally, only in the main process

@ZhangZheng-GIS
Copy link

Resolved issues, we don't use the vuex-electron to do it;

Hi, what did you change?

@ZhangZheng-GIS
Copy link

vuex-electron‘s createPersistedState method , depend electron-store <- conf <- write-file-atomic. and the method writeFileSync in write-file-atomic use fs.renameSync.

But, fs.renameSync Sometimes it goes wrong when multithreading because race condition。and every electron window is a rendering process。So,there is no solution until write-file-atomic solves the problem.

We can find that the root cause of the problem is multithreading, so here's an idea. We can also rewrite createPersistedState method to store data locally, only in the main process

Hi @zjruan, I used a background process and got this error. Is there a specific solution?

@espace-4-0
Copy link

Hi Guys,

Is the bug fixed ?

Best regards,
Lenaïc

@Gkiokan
Copy link

Gkiokan commented Jan 8, 2022

I got a fix for you guys. I struggled with that for my application on my windows users and it is really annoying.
However, I've found a valide workarround.

The error and crash happens due the thrown error in the plugin.
So you 2 options. Either you fix the race condition or you handle the Storage creation properly.

I am using 4 windows on my side and all of them have parallel access to the storage which makes everything complicated but however I could get it running without hassle once I put the creation in a while loop.

function createStore(){
    return new Vuex.Store({
      plugins: [
        pathify.plugin,
        createPersistedState({
          throttle: 1000,
          whitelist: (mutation) => true,
        }),
        createSharedMutations()
      ],
      modules
    })
}

let store

while(store === undefined){
  try {
      store = createStore()
      break;
  }
  catch(e){
      // alert("Error in Store, guess race condition. Recreating Storage." + e)
      continue;
  }
}

export default store

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants