fix(roles): resolve HTTP 429 errors on role management page (#39465)

Adapted for 6.0-release: only the fetchOptions.ts concurrency throttle (429
fix) applies. The RoleListEditModal.tsx/test.tsx changes (414 fix) depend on
the AsyncSelect architecture introduced in #38387, which is not present on
6.0; in 6.0 the modal receives permissions/groups as props from the parent
list page rather than fetching them itself with id-IN filters, so the 414
URL-length code path does not exist here.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
(cherry picked from commit f037449b75)
This commit is contained in:
Elizabeth Thompson
2026-05-28 13:34:54 -07:00
committed by Joe Li
parent 610d1c5998
commit 4e315fd769

View File

@@ -87,16 +87,21 @@ export const fetchPaginatedData = async ({
}
const totalPages = Math.ceil(totalItems / pageSize);
const concurrencyLimit = 5;
const allResults = [...firstPageResults];
const requests = Array.from({ length: totalPages - 1 }, (_, i) =>
fetchPage(i + 1),
);
const remainingResults = await Promise.all(requests);
for (let batch = 1; batch < totalPages; batch += concurrencyLimit) {
const batchEnd = Math.min(batch + concurrencyLimit, totalPages);
// eslint-disable-next-line no-await-in-loop
const batchResults = await Promise.all(
Array.from({ length: batchEnd - batch }, (_, i) =>
fetchPage(batch + i),
),
);
allResults.push(...batchResults.flatMap(res => res.results));
}
setData([
...firstPageResults,
...remainingResults.flatMap(res => res.results),
]);
setData(allResults);
} catch (err) {
addDangerToast(t(errorMessage));
} finally {