diff --git a/src/common/cluster-store.ts b/src/common/cluster-store.ts index 4000684d16..a2a5f0c3a1 100644 --- a/src/common/cluster-store.ts +++ b/src/common/cluster-store.ts @@ -124,36 +124,43 @@ export class ClusterStore extends BaseStore { } async load() { - await super.load(); - type clusterStateSync = { - id: string; - state: ClusterState; - }; + try { + await super.load(); - if (ipcRenderer) { - logger.info("[CLUSTER-STORE] requesting initial state sync"); - const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel); + type clusterStateSync = { + id: string; + state: ClusterState; + }; - clusterStates.forEach((clusterState) => { - const cluster = this.getById(clusterState.id); + if (ipcRenderer) { + logger.info("[CLUSTER-STORE] requesting initial state sync"); + const clusterStates: clusterStateSync[] = await requestMain(ClusterStore.stateRequestChannel); - if (cluster) { - cluster.setState(clusterState.state); - } - }); - } else { - handleRequest(ClusterStore.stateRequestChannel, (): clusterStateSync[] => { - const states: clusterStateSync[] = []; + clusterStates.forEach((clusterState) => { + const cluster = this.getById(clusterState.id); - this.clustersList.forEach((cluster) => { - states.push({ - state: cluster.getState(), - id: cluster.id - }); + if (cluster) { + cluster.setState(clusterState.state); + } }); + } else { + handleRequest(ClusterStore.stateRequestChannel, (): clusterStateSync[] => { + const states: clusterStateSync[] = []; - return states; - }); + this.clustersList.forEach((cluster) => { + states.push({ + state: cluster.getState(), + id: cluster.id + }); + }); + + return states; + }); + } + } catch (error) { + logger.error("[CLUSTER-STORE] error loading: ", error); + this.fromStore(); + this.isLoaded = true; } } diff --git a/src/common/workspace-store.ts b/src/common/workspace-store.ts index 921a9126a9..aafd47ba14 100644 --- a/src/common/workspace-store.ts +++ b/src/common/workspace-store.ts @@ -160,36 +160,40 @@ export class WorkspaceStore extends BaseStore { } async load() { - await super.load(); - type workspaceStateSync = { - id: string; - state: WorkspaceState; - }; + try { + await super.load(); + type workspaceStateSync = { + id: string; + state: WorkspaceState; + }; - if (ipcRenderer) { - logger.info("[WORKSPACE-STORE] requesting initial state sync"); - const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel); + if (ipcRenderer) { + logger.info("[WORKSPACE-STORE] requesting initial state sync"); + const workspaceStates: workspaceStateSync[] = await requestMain(WorkspaceStore.stateRequestChannel); - workspaceStates.forEach((workspaceState) => { - const workspace = this.getById(workspaceState.id); + workspaceStates.forEach((workspaceState) => { + const workspace = this.getById(workspaceState.id); - if (workspace) { - workspace.setState(workspaceState.state); - } - }); - } else { - handleRequest(WorkspaceStore.stateRequestChannel, (): workspaceStateSync[] => { - const states: workspaceStateSync[] = []; - - this.workspacesList.forEach((workspace) => { - states.push({ - state: workspace.getState(), - id: workspace.id - }); + if (workspace) { + workspace.setState(workspaceState.state); + } }); + } else { + handleRequest(WorkspaceStore.stateRequestChannel, (): workspaceStateSync[] => { + const states: workspaceStateSync[] = []; - return states; - }); + this.workspacesList.forEach((workspace) => { + states.push({ + state: workspace.getState(), + id: workspace.id + }); + }); + + return states; + }); + } + } catch (error) { + logger.error("[WORKSPACE-STORE] error loading: ", { error }); } } diff --git a/src/main/index.ts b/src/main/index.ts index 9a0b11b626..51e1e4e8c8 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -103,7 +103,7 @@ app.on("ready", async () => { logger.info("💾 Loading stores"); // preload - await Promise.all([ + await Promise.allSettled([ userStore.load(), clusterStore.load(), workspaceStore.load(),