fix(webapp): timestamp live metric responses - #4719
Conversation
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| responseReceivedAt !== null && | ||
| lastLiveBlockRow && | ||
| Number.isFinite(lastLiveBucketMs) && | ||
| Date.now() - lastLiveBucketMs < LIVE_GAUGE_FRESH_MS | ||
| responseReceivedAt - lastLiveBucketMs < LIVE_GAUGE_FRESH_MS |
There was a problem hiding this comment.
🔍 Freshness now anchors to the last successful response, so a hung/paused poll can keep a stale gauge marked fresh
The three call sites now compare the newest ClickHouse bucket against the timestamp of the last successful response rather than wall-clock Date.now(). That correctly stops cache-painted rows (responseCache in apps/webapp/app/hooks/useMetricResourceQuery.ts:33) from being trusted, but it also means the freshness window no longer advances with real time: if polling stalls (a request that never resolves, or the tab hidden for a long time with pauseWhenHidden in apps/webapp/app/hooks/useMetricResourceQuery.ts:186-192), the pair (rows, responseReceivedAt) stays frozen and keeps satisfying responseReceivedAt - bucketMs < LIVE_GAUGE_FRESH_MS, so an arbitrarily old count is still shown as live until the next response lands. Previously Date.now() made it age out. A failed poll does reset to null (falling back to loader values), so this only affects the never-resolving / paused cases, and the visible window on refocus is short — hence not reported as a bug, but worth confirming it's the intended trade-off.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
Records when live metric responses arrive and uses that timestamp to evaluate gauge freshness and waiting duration. Cached or failed responses remain untrusted until revalidated, while rendered values stay stable between polling updates.