Skip to content

Commit d8b3c3a

Browse files
kadu-jrAJIXuMuK
authored andcommitted
Added extra condition to prevent infinite loop when fetching sites
1 parent e12cb3e commit d8b3c3a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/services/SPSitesService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const getAllSitesInternal = async (ctx: BaseComponentContext, queryText: string,
3737
let startRow = 0;
3838
const rowLimit = 500;
3939
let totalRows = 0;
40+
let currentRows = 0;
4041
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4142
const values: any[] = [];
4243

@@ -70,8 +71,9 @@ const getAllSitesInternal = async (ctx: BaseComponentContext, queryText: string,
7071
values.push(...relevantResults.Table.Rows);
7172
totalRows = relevantResults.TotalRows;
7273
startRow += rowLimit;
74+
currentRows = relevantResults.Table.Rows?.length;
7375

74-
} while (values.length < totalRows);
76+
} while (values.length < totalRows && currentRows !== 0);
7577

7678
// Do the call against the SP REST API search endpoint
7779

0 commit comments

Comments
 (0)