From 64225f6c80152b8ab6dc1d18684dd3e18f05b0a2 Mon Sep 17 00:00:00 2001 From: Gkiokan Sali Date: Sat, 8 Jan 2022 17:28:30 +0100 Subject: [PATCH] Fix Storage Error by while loop and add proper global errorHandler --- package-lock.json | 2 +- package.json | 5 ++++- src/renderer/index.js | 3 +++ src/renderer/store/index.js | 39 ++++++++++++++++++++++++++----------- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5a1c7cb..8969661 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "PS4RemotePKGSenderV2", - "version": "2.4.0", + "version": "2.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f7d9dcc..06218c8 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,10 @@ "output": "release" }, "win": { - "target": ["zip", "portable"] + "target": [ + "zip", + "portable" + ] }, "portable": { "artifactName": "${productName}.exe", diff --git a/src/renderer/index.js b/src/renderer/index.js index b10259d..63787d3 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -26,6 +26,9 @@ styles.innerText=`@import url(https://unpkg.com/spectre.css/dist/spectre.min.css Vue.config.devtools = process.env.NODE_ENV !== 'production', Vue.config.productionTip = false, +Vue.config.errorHandler = (error, vm, info) => { + alert("Application global errorHandler:\n" + error) +} new Vue({ router, diff --git a/src/renderer/store/index.js b/src/renderer/store/index.js index 0bca6df..462a1f3 100644 --- a/src/renderer/store/index.js +++ b/src/renderer/store/index.js @@ -21,14 +21,31 @@ const modules = requireContext.keys() return { ...modules, [name]: module } }, {}) -export default new Vuex.Store({ - plugins: [ - pathify.plugin, - createPersistedState({ - throttle: 3300, - whitelist: (mutation) => true, - }), - createSharedMutations() - ], - modules -}) +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