From 9ed590d92a6a8a5957d7181110e1171adca71f69 Mon Sep 17 00:00:00 2001 From: Diljit VJ Date: Tue, 8 Apr 2025 18:15:26 +0530 Subject: [PATCH] chore: log evaluation error logs and push execption to sentry --- app/client/src/sagas/EvalErrorHandler.ts | 31 ++++++++++--------- app/client/src/utils/DynamicBindingUtils.ts | 1 + .../workers/Evaluation/handlers/evalTree.ts | 21 ++++++------- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/app/client/src/sagas/EvalErrorHandler.ts b/app/client/src/sagas/EvalErrorHandler.ts index 7fe52a4a739a..812c29e916b7 100644 --- a/app/client/src/sagas/EvalErrorHandler.ts +++ b/app/client/src/sagas/EvalErrorHandler.ts @@ -255,35 +255,35 @@ export function* evalErrorHandler( }); } + log.error(error); + break; } case EvalErrorTypes.EVAL_TREE_ERROR: { toast.show(createMessage(ERROR_EVAL_ERROR_GENERIC), { kind: "error", }); + log.error(error); + Sentry.captureException(error); break; } case EvalErrorTypes.BAD_UNEVAL_TREE_ERROR: { + log.error(error); Sentry.captureException(error); break; } case EvalErrorTypes.EVAL_PROPERTY_ERROR: { - log.debug(error); + Sentry.captureException(error); + log.error(error); break; } case EvalErrorTypes.CLONE_ERROR: { - /* - * https://github.com/appsmithorg/appsmith/issues/2654 - * This code is being commented out to prevent these errors from going to Sentry - * till we come up with a more definitive solution to prevent this error - * Proposed solution - adding lint errors to editor to prevent these from happening - * */ - - // Sentry.captureException(new Error(error.message), { - // extra: { - // request: error.context, - // }, - // }); + log.debug(error); + Sentry.captureException(new Error(error.message), { + extra: { + request: error.context, + }, + }); break; } case EvalErrorTypes.PARSE_JS_ERROR: { @@ -293,6 +293,8 @@ export function* evalErrorHandler( AppsmithConsole.error({ text: `${error.message} at: ${error.context?.propertyPath}`, }); + log.error(error); + Sentry.captureException(error); break; } case EvalErrorTypes.EXTRACT_DEPENDENCY_ERROR: { @@ -302,7 +304,8 @@ export function* evalErrorHandler( break; } default: { - log.debug(error); + log.error(error); + Sentry.captureException(error); } } }); diff --git a/app/client/src/utils/DynamicBindingUtils.ts b/app/client/src/utils/DynamicBindingUtils.ts index 897a674652b7..684a54628660 100644 --- a/app/client/src/utils/DynamicBindingUtils.ts +++ b/app/client/src/utils/DynamicBindingUtils.ts @@ -168,6 +168,7 @@ export interface EvalError { // TODO: Fix this the next time the file is edited // eslint-disable-next-line @typescript-eslint/no-explicit-any context?: Record; + stack?: string; } export interface DynamicPath { diff --git a/app/client/src/workers/Evaluation/handlers/evalTree.ts b/app/client/src/workers/Evaluation/handlers/evalTree.ts index cc16a6e0bc25..707c72b8e7d6 100644 --- a/app/client/src/workers/Evaluation/handlers/evalTree.ts +++ b/app/client/src/workers/Evaluation/handlers/evalTree.ts @@ -10,10 +10,7 @@ import type { EvalMetaUpdates } from "ee/workers/common/DataTreeEvaluator/types" import { makeEntityConfigsAsObjProperties } from "ee/workers/Evaluation/dataTreeUtils"; import type { DataTreeDiff } from "ee/workers/Evaluation/evaluationUtils"; import { serialiseToBigInt } from "ee/workers/Evaluation/evaluationUtils"; -import { - CrashingError, - getSafeToRenderDataTree, -} from "ee/workers/Evaluation/evaluationUtils"; +import { getSafeToRenderDataTree } from "ee/workers/Evaluation/evaluationUtils"; import type { EvalTreeRequestData, EvalWorkerASyncRequest } from "../types"; import { clearAllIntervals } from "../fns/overrides/interval"; import JSObjectCollection from "workers/Evaluation/JSObject/Collection"; @@ -272,14 +269,14 @@ export async function evalTree( logs = dataTreeEvaluator.logs; } - if (!(error instanceof CrashingError)) { - errors.push({ - type: EvalErrorTypes.UNKNOWN_ERROR, - message: (error as Error).message, - }); - // eslint-disable-next-line - console.error(error); - } + errors.push({ + type: EvalErrorTypes.EVAL_TREE_ERROR, + message: (error as Error).message, + stack: (error as Error).stack, + }); + + // eslint-disable-next-line + console.error(error); dataTree = getSafeToRenderDataTree( makeEntityConfigsAsObjProperties(unevalTree, {