Improve information for cyclic dependency error (#5949)

This commit is contained in:
Hetu Nandu 2021-07-20 16:20:22 +05:30 committed by GitHub
parent 745927ffef
commit 7063ee9d2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -177,7 +177,7 @@ export function* evalErrorHandler(
case EvalErrorTypes.CYCLICAL_DEPENDENCY_ERROR: {
if (error.context) {
// Add more info about node for the toast
const { entityType, node } = error.context;
const { dependencyMap, diffs, entityType, node } = error.context;
Toaster.show({
text: `${error.message} Node was: ${node}`,
variant: Variant.danger,
@ -191,6 +191,10 @@ export function* evalErrorHandler(
node,
entityType,
},
extra: {
dependencyMap,
diffs,
},
// Level is warning because it could be a user error
level: Sentry.Severity.Warning,
});

View File

@ -26,6 +26,7 @@ import {
addErrorToEntityProperty,
convertPathToString,
CrashingError,
DataTreeDiff,
DataTreeDiffEvent,
getAllPaths,
getEntityNameAndPropertyPath,
@ -483,7 +484,10 @@ export default class DataTreeEvaluator {
}
}
sortDependencies(dependencyMap: DependencyMap): Array<string> {
sortDependencies(
dependencyMap: DependencyMap,
diffs?: (DataTreeDiff | DataTreeDiff[])[],
): Array<string> {
const dependencyTree: Array<[string, string]> = [];
Object.keys(dependencyMap).forEach((key: string) => {
if (dependencyMap[key].length) {
@ -519,6 +523,8 @@ export default class DataTreeEvaluator {
context: {
node,
entityType,
dependencyMap,
diffs,
},
});
console.error("CYCLICAL DEPENDENCY MAP", dependencyMap);
@ -949,7 +955,10 @@ export default class DataTreeEvaluator {
// global inverse dependency map
if (didUpdateDependencyMap) {
// This is being called purely to test for new circular dependencies that might have been added
this.sortedDependencies = this.sortDependencies(this.dependencyMap);
this.sortedDependencies = this.sortDependencies(
this.dependencyMap,
translatedDiffs,
);
this.inverseDependencyMap = this.getInverseDependencyTree();
}

View File

@ -36,7 +36,7 @@ export enum DataTreeDiffEvent {
NOOP = "NOOP",
}
type DataTreeDiff = {
export type DataTreeDiff = {
payload: {
propertyPath: string;
value?: string;