Skip to content

Conversation

@Zylphrex
Copy link
Member

@Zylphrex Zylphrex commented Oct 24, 2025

Previously, the flex time strategy could result in a really long loading state. This change shows a live progress with the bytes scanned in the loading state to indicate we're still working on it.

Closes LOGS-438

Previously, the flex time strategy could result in a really long loading state.
This change shows a live progress with the bytes scanned in the loading state to
indicate we're still working on it.
@Zylphrex Zylphrex requested a review from a team as a code owner October 24, 2025 20:16
@linear
Copy link

linear bot commented Oct 24, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Oct 24, 2025
cursor[bot]

This comment was marked as outdated.

Comment on lines +596 to +606
setTotalBytesScanned(0);
return;
}

const bytesScanned = lastPage[0].meta?.bytesScanned;
if (!defined(bytesScanned)) {
return;
}

setTotalBytesScanned(previousBytesScanned => previousBytesScanned + bytesScanned);
}, [lastPage]);
Copy link

Choose a reason for hiding this comment

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

Bug: The useEffect accumulates bytesScanned multiple times for the same page due to lastPage reference changes on React Query state updates.
Severity: CRITICAL | Confidence: 1.00

🔍 Detailed Analysis

The useEffect hook responsible for accumulating bytesScanned re-runs unnecessarily because its dependency, lastPage, receives a new object reference on every React Query state update, even if the underlying page data has not changed. This causes the bytesScanned value from the same page to be added multiple times to totalBytesScanned, leading to an inflated and incorrect total displayed to the user. This occurs whenever React Query updates its internal state, such as when isPending changes, triggering the effect with a new lastPage reference that points to the same data.

💡 Suggested Fix

Modify the useEffect to ensure bytesScanned is added only once per unique lastPage data object. This can be achieved by tracking a stable identifier from lastPage (e.g., lastPage.id or a unique hash of its content) and only performing the accumulation if this identifier has not been processed before.

🤖 Prompt for AI Agent
Fix this bug. In static/app/views/explore/logs/useLogsQuery.tsx at lines 587-606: The
`useEffect` hook responsible for accumulating `bytesScanned` re-runs unnecessarily
because its dependency, `lastPage`, receives a new object reference on every React Query
state update, even if the underlying page data has not changed. This causes the
`bytesScanned` value from the same page to be added multiple times to
`totalBytesScanned`, leading to an inflated and incorrect total displayed to the user.
This occurs whenever React Query updates its internal state, such as when `isPending`
changes, triggering the effect with a new `lastPage` reference that points to the same
data.

Did we get this right? 👍 / 👎 to inform future reviews.

@Zylphrex Zylphrex merged commit 52b0014 into master Oct 27, 2025
47 checks passed
@Zylphrex Zylphrex deleted the txiao/feat/add-better-loading-state-for-flex-time-strategy branch October 27, 2025 16:12
priscilawebdev pushed a commit that referenced this pull request Oct 28, 2025
Previously, the flex time strategy could result in a really long loading
state. This change shows a live progress with the bytes scanned in the
loading state to indicate we're still working on it.

Closes LOGS-438
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.

3 participants