From 526f2a8be643275d543c2d9d6361e930c2eaa43d Mon Sep 17 00:00:00 2001 From: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com> Date: Wed, 27 Jul 2022 16:25:41 +0530 Subject: [PATCH] chore: fix cannot read properties of null (reading 'id') sentry error (#15323) --- .../src/entities/Engine/AppEditorEngine.ts | 20 +++++++++++++++---- .../src/entities/Engine/AppViewerEngine.ts | 7 +++++-- app/client/src/entities/Engine/index.ts | 6 +++++- app/client/src/sagas/InitSagas.ts | 4 ++-- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/app/client/src/entities/Engine/AppEditorEngine.ts b/app/client/src/entities/Engine/AppEditorEngine.ts index 0c71dd6cf9..aa647c19c1 100644 --- a/app/client/src/entities/Engine/AppEditorEngine.ts +++ b/app/client/src/entities/Engine/AppEditorEngine.ts @@ -40,7 +40,12 @@ import history from "utils/history"; import PerformanceTracker, { PerformanceTransactionName, } from "utils/PerformanceTracker"; -import AppEngine, { AppEnginePayload } from "."; +import AppEngine, { + ActionsNotFoundError, + AppEnginePayload, + PluginFormConfigsNotFoundError, + PluginsNotFoundError, +} from "."; export default class AppEditorEngine extends AppEngine { constructor(mode: APP_MODE) { @@ -114,7 +119,10 @@ export default class AppEditorEngine extends AppEngine { failureActionEffects, ); - if (!allActionCalls) return; + if (!allActionCalls) + throw new ActionsNotFoundError( + `Unable to fetch actions for the application: ${applicationId}`, + ); yield put(fetchAllPageEntityCompletion([executePageLoadActions()])); } @@ -147,7 +155,8 @@ export default class AppEditorEngine extends AppEngine { errorActions, ); - if (!initActionCalls) return; + if (!initActionCalls) + throw new PluginsNotFoundError("Unable to fetch plugins"); const pluginFormCall: boolean = yield call( failFastApiCalls, @@ -155,7 +164,10 @@ export default class AppEditorEngine extends AppEngine { [ReduxActionTypes.FETCH_PLUGIN_FORM_CONFIGS_SUCCESS], [ReduxActionErrorTypes.FETCH_PLUGIN_FORM_CONFIGS_ERROR], ); - if (!pluginFormCall) return; + if (!pluginFormCall) + throw new PluginFormConfigsNotFoundError( + "Unable to fetch plugin form configs", + ); } public *loadAppEntities(toLoadPageId: string, applicationId: string): any { diff --git a/app/client/src/entities/Engine/AppViewerEngine.ts b/app/client/src/entities/Engine/AppViewerEngine.ts index 2bbe901fa7..13da15e2b0 100644 --- a/app/client/src/entities/Engine/AppViewerEngine.ts +++ b/app/client/src/entities/Engine/AppViewerEngine.ts @@ -23,7 +23,7 @@ import { failFastApiCalls } from "sagas/InitSagas"; import PerformanceTracker, { PerformanceTransactionName, } from "utils/PerformanceTracker"; -import AppEngine, { AppEnginePayload } from "."; +import AppEngine, { ActionsNotFoundError, AppEnginePayload } from "."; export default class AppViewerEngine extends AppEngine { constructor(mode: APP_MODE) { @@ -93,7 +93,10 @@ export default class AppViewerEngine extends AppEngine { ], ); - if (!resultOfPrimaryCalls) return; + if (!resultOfPrimaryCalls) + throw new ActionsNotFoundError( + `Unable to fetch actions for the application: ${applicationId}`, + ); yield put(fetchAllPageEntityCompletion([executePageLoadActions()])); } diff --git a/app/client/src/entities/Engine/index.ts b/app/client/src/entities/Engine/index.ts index 745a84b35f..45ea8e0202 100644 --- a/app/client/src/entities/Engine/index.ts +++ b/app/client/src/entities/Engine/index.ts @@ -33,7 +33,11 @@ export interface IAppEngine { completeChore(): any; } -export class PageNotFoundError extends Error {} +export class AppEngineApiError extends Error {} +export class PageNotFoundError extends AppEngineApiError {} +export class ActionsNotFoundError extends AppEngineApiError {} +export class PluginsNotFoundError extends AppEngineApiError {} +export class PluginFormConfigsNotFoundError extends AppEngineApiError {} export default abstract class AppEngine { private _mode: APP_MODE; diff --git a/app/client/src/sagas/InitSagas.ts b/app/client/src/sagas/InitSagas.ts index 9cae4930b4..a12b920d1f 100644 --- a/app/client/src/sagas/InitSagas.ts +++ b/app/client/src/sagas/InitSagas.ts @@ -32,8 +32,8 @@ import { getIsInitialized as getIsViewerInitialized } from "selectors/appViewSel import { enableGuidedTour } from "actions/onboardingActions"; import { setPreviewModeAction } from "actions/editorActions"; import AppEngine, { + AppEngineApiError, AppEnginePayload, - PageNotFoundError, } from "entities/Engine"; import AppEngineFactory from "entities/Engine/factory"; import { ApplicationPagePayload } from "api/ApplicationApi"; @@ -95,8 +95,8 @@ export function* startAppEngine(action: ReduxAction) { engine.stopPerformanceTracking(); } catch (e) { log.error(e); + if (e instanceof AppEngineApiError) return; Sentry.captureException(e); - if (e instanceof PageNotFoundError) return; yield put({ type: ReduxActionTypes.SAFE_CRASH_APPSMITH_REQUEST, payload: {