fix(editor): Fix cloud plan data loading on instance (#7841)

Moving cloud hooks and store initialization logic after users are
authenticated. This will ensure user local account is available when
their cloud plan data is being fetched.
This PR also adds the following error handling improvements:
- Added error handling to the same initialization logic
- Fixed empty `catch` clauses inside the cloud store which caused it to
silently fail and complicated debugging of this bug
This commit is contained in:
Milorad FIlipović
2023-11-29 10:51:15 +01:00
committed by GitHub
parent 90bb6ba417
commit 8b99384367
7 changed files with 136 additions and 13 deletions

View File

@@ -19,13 +19,17 @@ export async function initializeCore() {
}
const settingsStore = useSettingsStore();
const cloudPlanStore = useCloudPlanStore();
const usersStore = useUsersStore();
await settingsStore.initialize();
await usersStore.initialize();
if (settingsStore.isCloudDeployment) {
await Promise.all([cloudPlanStore.initialize(), initializeCloudHooks()]);
try {
await initializeCloudHooks();
} catch (e) {
console.error('Failed to initialize cloud hooks:', e);
}
}
coreInitialized = true;
@@ -48,6 +52,7 @@ export async function initializeAuthenticatedFeatures() {
const settingsStore = useSettingsStore();
const rootStore = useRootStore();
const nodeTypesStore = useNodeTypesStore();
const cloudPlanStore = useCloudPlanStore();
if (sourceControlStore.isEnterpriseSourceControlEnabled) {
await sourceControlStore.getPreferences();
@@ -63,5 +68,13 @@ export async function initializeAuthenticatedFeatures() {
await nodeTypesStore.getNodeTranslationHeaders();
}
if (settingsStore.isCloudDeployment) {
try {
await cloudPlanStore.initialize();
} catch (e) {
console.error('Failed to initialize cloud plan store:', e);
}
}
authenticatedFeaturesInitialized = true;
}