fix(frontend): entry deduplication#5061
Conversation
|
PR Review: fix(frontend): entry deduplication Overview This PR fixes duplicate log entries in useDeploymentLogsStream by introducing a seenInsertIdsRef set that tracks seen insertId values across three boundaries: the initial history fetch, the live SSE stream, and load-more pagination. It also fixes a missing setHasMore(false) call for the initial history fetch and adds Sentry observability for a previously silent catch block. The approach is correct and the problem is real. Timestamp-cursor pagination inherently produces overlaps at page boundaries, and history/stream overlap is an inherent race. Issues Unguarded insertId in the live-stream path (medium) If entry.data.insertId is undefined or null, every subsequent entry without an insertId would be silently dropped - Set.has(undefined) returns true after the first Set.add(undefined). The history path already sidesteps this because it iterates and bulk-adds before any dedup check, but the stream path has a hard gate. A minimal guard keeps it safe. Load-more can silently no-op when a full page is entirely duplicates (low) hasMore is set based on the raw items.length (correct, because the API may have more pages), but if fresh.length === 0 the user clicks load more, sees nothing, and the button stays enabled indefinitely. An auto-retry or user-facing message in this case would improve UX, though this edge case is rare in practice. Sentry context includes filter (low) filter is a free-text search term entered by the user and could contain sensitive strings. Confirm that Sentry data-scrubbing rules cover this field, or omit filter from the context. Positive observations
Minor nits The hasMore reset useEffect is necessary because the main useEffect only calls setHasMore(false) conditionally. Without it hasMore could be stale-false after a filter change. The logic is correct but the relationship between the two effects is not immediately obvious. A brief comment noting why this reset lives in a separate effect would help future readers. Overall this is a clear, well-scoped fix. The insertId guard in the live-stream path is the only item worth calling a blocking concern before merge. |
0401c60 to
17b97a5
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: