Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/client/src/ce/workers/Evaluation/evaluationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ export function getExternalChangedDependencies(
}

export const isDataPath = (
entity: DataTreeEntity,
entity: DataTreeEntity | Partial<DataTreeEntityConfig>,
fullPropertyPath: string,
) => {
if (isWidget(entity)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,6 @@ export function getJSDependencies(
dependencies = { ...dependencies, [fullPropertyPath]: newDeps };
}

for (const funcName of jsActionConfig.actionNames) {
const func = jsEntity[funcName];

Comment thread
ankitakinger marked this conversation as resolved.
if (func) {
dependencies[`${jsObjectName}.${funcName}.data`] = [
`${jsObjectName}.${funcName}`,
];
}
}

return dependencies;
}
export function getActionDependencies(
Expand Down
65 changes: 39 additions & 26 deletions app/client/src/entities/DependencyMap/DependencyMapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
getEntityNameAndPropertyPath,
IMMEDIATE_PARENT_REGEX,
isActionConfig,
isDataPath,
isJSActionConfig,
isWidget,
} from "ee/workers/Evaluation/evaluationUtils";
import type { ConfigTree } from "entities/DataTree/dataTreeTypes";
import { isPathDynamicTrigger } from "utils/DynamicBindingUtils";
Expand Down Expand Up @@ -167,10 +169,6 @@ export class DependencyMapUtils {
return false;
}

static isDataPath(path: string) {
return path.endsWith(".data");
}

static detectReactiveDependencyMisuse(
dependencyMap: DependencyMap,
configTree: ConfigTree,
Expand Down Expand Up @@ -213,27 +211,34 @@ export class DependencyMapUtils {
);

for (const dep of transitiveDeps) {
if (this.isTriggerPath(dep, configTree)) {
hasRun = true;
runPath = dep;
}

if (this.isDataPath(dep)) {
hasData = true;
dataPath = dep;
}

if (
hasRun &&
hasData &&
runPath.split(".")[0] === dataPath.split(".")[0]
) {
throw Object.assign(
new Error(
`Reactive dependency misuse: '${node}' depends on both trigger path '${runPath}' and data path '${dataPath}' from the same entity. This can cause unexpected reactivity.`,
),
{ node, triggerPath: runPath, dataPath },
);
const { entityName: depName } = getEntityNameAndPropertyPath(dep);
const entity = configTree[depName];

// to show cyclic dependency errors only for Action calls and not JSObject.body or JSObject
if (entity && entity.ENTITY_TYPE === "ACTION") {
Comment thread
ankitakinger marked this conversation as resolved.
Outdated
if (this.isTriggerPath(dep, configTree)) {
hasRun = true;
runPath = dep;
}

// using the isDataPath function from evalUtils to calculate data paths based on entity type
if (isDataPath(entity, dep)) {
hasData = true;
dataPath = dep;
}

if (
hasRun &&
hasData &&
runPath.split(".")[0] === dataPath.split(".")[0]
) {
throw Object.assign(
new Error(
`Reactive dependency misuse: '${node}' depends on both trigger path '${runPath}' and data path '${dataPath}' from the same entity. This can cause unexpected reactivity.`,
),
{ node, triggerPath: runPath, dataPath },
);
}
}
}
}
Expand All @@ -256,7 +261,15 @@ export class DependencyMapUtils {

if (!entityConfig) return;

if (!isActionConfig(entityConfig) && !isJSActionConfig(entityConfig)) {
if (isWidget(entityConfig)) {
return;
}

// to not calculate transitive dependencies for JSObject.body and JSObject
if (
isJSActionConfig(entityConfig) &&
Comment thread
ankitakinger marked this conversation as resolved.
(current.includes(".body") || !current.includes("."))
) {
return;
}

Expand Down
Loading