chore: log evaluation error logs and push execption to sentry (#40170)

## Description
This PR makes sure that any error in evaluation is not supressed by the
code and when it happens it does the following
- Shows a generic evaluation error to the user as a toast message
- Log the error in the main thread console
- Send an exception to Sentry

Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.All"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Enhanced error logging and reporting to ensure evaluation issues are
consistently captured and tracked.
  
- **Chores**
- Expanded error diagnostics by including additional context for
improved troubleshooting.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Diljit 2025-04-08 22:04:56 +05:30 committed by GitHub
parent 00adc9ee62
commit 410e4ea999
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 26 deletions

View File

@ -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);
}
}
});

View File

@ -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<string, any>;
stack?: string;
}
export interface DynamicPath {

View File

@ -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, {