Giter Site home page Giter Site logo

Comments (7)

zjruan avatar zjruan commented on June 30, 2024 2

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

from vuex-electron.

mxj7000 avatar mxj7000 commented on June 30, 2024

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

from vuex-electron.

akodkod avatar akodkod commented on June 30, 2024

#44

from vuex-electron.

ZhangZheng-GIS avatar ZhangZheng-GIS commented on June 30, 2024

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

Hi, what did you change?

from vuex-electron.

ZhangZheng-GIS avatar ZhangZheng-GIS commented on June 30, 2024

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?

from vuex-electron.

espace-4-0 avatar espace-4-0 commented on June 30, 2024

Hi Guys,

Is the bug fixed ?

Best regards,
Lenaïc

from vuex-electron.

Gkiokan avatar Gkiokan commented on June 30, 2024

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

from vuex-electron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.