Skip to content

fix(explore): increase logs infinite query maxPages when we don't have many rows locally#112691

Merged
JoshuaKGoldberg merged 3 commits intomasterfrom
dynamic-max-pages
Apr 15, 2026
Merged

fix(explore): increase logs infinite query maxPages when we don't have many rows locally#112691
JoshuaKGoldberg merged 3 commits intomasterfrom
dynamic-max-pages

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Apr 10, 2026

Previously, the maxPages for infinitely querying logs was hardcoded to 30 (MAX_LOGS_INFINITE_QUERY_PAGES). This is good in case there are many big logs to amke sure the local browser doesn't run out of data. But if there are many "blank" pages (gaps) of query results, which can happen when the logs are very sporadic, we end up hitting the maximum page limit for queries and losing some.

This goes for a higher 300 (MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED) when there are fewer than 500 (LOCAL_LOG_ROWS_FOR_EXPANDED_INFINITE_PAGES) rows locally. We're thinking this should allow more pages so we don't bump into the max storage - while not risking running out of browser memory.

Fixes EXP-865

Made with Cursor

The RCA and solution idea for this came from @k-fish (🥔), so essentially:

Co-authored-by: @k-fish

Use a lower page cap until enough rows are cached locally, then allow a higher cap.

Co-Authored-By: Cursor Agent <noreply@cursor.com>
Made-with: Cursor
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 10, 2026
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 13, 2026

@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(explore): Vary logs infinite query maxPages by cached rows fix(explore): increase logs infinite query maxPages when we don't have many rows locally Apr 13, 2026
@JoshuaKGoldberg JoshuaKGoldberg requested a review from k-fish April 13, 2026 13:59
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review April 13, 2026 13:59
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner April 13, 2026 13:59
Comment thread static/app/views/explore/logs/useLogsQuery.tsx Outdated
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Inverted condition returns wrong maxPages limit
    • Inverted the ternary condition so that fewer rows (<500) returns the higher limit (300) and more rows (≥500) returns the lower limit (30), and corrected the JSDoc comment.

Create PR

Or push these changes by commenting:

@cursor push 403f4fffa2
Preview (403f4fffa2)
diff --git a/static/app/views/explore/logs/constants.tsx b/static/app/views/explore/logs/constants.tsx
--- a/static/app/views/explore/logs/constants.tsx
+++ b/static/app/views/explore/logs/constants.tsx
@@ -22,7 +22,7 @@
 export const MAX_LOGS_INFINITE_QUERY_PAGES = 30; // This number * the refresh interval must be more seconds than 2 * the smallest time interval in the chart for streaming to work.
 /** Larger page cap once enough rows are cached (see useInfiniteLogsQuery). */
 export const MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED = 300;
-/** Below this many rows in the client cache, use {@link MAX_LOGS_INFINITE_QUERY_PAGES}. */
+/** Below this many rows in the client cache, use {@link MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED}. */
 export const LOCAL_LOG_ROWS_FOR_EXPANDED_INFINITE_PAGES = 500;
 
 /**

diff --git a/static/app/views/explore/logs/useLogsQuery.tsx b/static/app/views/explore/logs/useLogsQuery.tsx
--- a/static/app/views/explore/logs/useLogsQuery.tsx
+++ b/static/app/views/explore/logs/useLogsQuery.tsx
@@ -414,8 +414,8 @@
   const rows =
     cached?.pages?.reduce((n, page) => n + (page[0]?.data?.length ?? 0), 0) ?? 0;
   return rows < LOCAL_LOG_ROWS_FOR_EXPANDED_INFINITE_PAGES
-    ? MAX_LOGS_INFINITE_QUERY_PAGES
-    : MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED;
+    ? MAX_LOGS_INFINITE_QUERY_PAGES_EXPANDED
+    : MAX_LOGS_INFINITE_QUERY_PAGES;
 }
 
 export function useInfiniteLogsQuery({

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aec7539. Configure here.

Comment thread static/app/views/explore/logs/useLogsQuery.tsx Outdated
@JoshuaKGoldberg JoshuaKGoldberg merged commit 39f4fa5 into master Apr 15, 2026
65 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the dynamic-max-pages branch April 15, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants