From 7ee4833764122ad9affdb22942743d4bc33c8399 Mon Sep 17 00:00:00 2001 From: Ceder Dens Date: Fri, 5 Jun 2026 20:16:12 +0200 Subject: [PATCH] Apply fetching pages in batches suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- .../LogDetailsDrawer/LogDetailsDrawer.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx index e13a984ae02..af21765d685 100644 --- a/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/LogDetailsDrawer/LogDetailsDrawer.tsx @@ -133,11 +133,17 @@ export function LogDetailsDrawer({ const pagesToFetch = Math.min(firstPage.total_pages ?? 1, MAX_SESSION_PAGES); if (pagesToFetch > 1) { - const remaining = await Promise.all( - Array.from({ length: pagesToFetch - 1 }, (_, i) => - sessionSpendLogsCall(accessToken, sessionId, i + 2, SESSION_PAGE_SIZE), - ), - ); + const BATCH = 5; + const remaining: Awaited>[] = []; + for (let start = 2; start <= pagesToFetch; start += BATCH) { + const end = Math.min(start + BATCH - 1, pagesToFetch); + const batch = await Promise.all( + Array.from({ length: end - start + 1 }, (_, i) => + sessionSpendLogsCall(accessToken, sessionId, start + i, SESSION_PAGE_SIZE), + ), + ); + remaining.push(...batch); + } for (const page of remaining) { rows = rows.concat(page.data || []); }