Skip to content

Commit 9082011

Browse files
committed
add logic to deal with invalidation cycles
1 parent b0ec869 commit 9082011

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: packages/runtime-common/indexer.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,13 @@ export class Batch {
10981098
}
10991099
}
11001100

1101-
private async calculateInvalidations(alias: string): Promise<string[]> {
1101+
private async calculateInvalidations(
1102+
alias: string,
1103+
visited: string[] = [],
1104+
): Promise<string[]> {
1105+
if (visited.includes(alias)) {
1106+
return [];
1107+
}
11021108
let childInvalidations = await this.client.itemsThatReference(
11031109
alias,
11041110
this.realmVersion,
@@ -1109,7 +1115,9 @@ export class Batch {
11091115
...invalidations,
11101116
...flatten(
11111117
await Promise.all(
1112-
aliases.map((alias) => this.calculateInvalidations(alias)),
1118+
aliases.map((a) =>
1119+
this.calculateInvalidations(a, [...visited, alias]),
1120+
),
11131121
),
11141122
),
11151123
];

0 commit comments

Comments
 (0)