fix: prevent infinite loop on TraceDiff with empty trace IDs#3714
fix: prevent infinite loop on TraceDiff with empty trace IDs#3714yurishkuro merged 1 commit intojaegertracing:mainfrom
Conversation
Signed-off-by: Parship Chowdhury <parshipchowdhury@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes an infinite loop issue that occurred when navigating to the trace comparison URL with no trace IDs (e.g., /trace/...). The root cause was a mismatch between how the Zustand store (which uses null for empty trace IDs) and the URL parser (which produces undefined for empty segments) represented the same concept, causing syncStates to continuously trigger state synchronization. The fix normalizes both undefined and null to null in the comparison using the nullish coalescing operator, preventing the infinite loop.
Changes:
- Modified the
syncStatesfunction to normalizeundefinedandnullvalues when comparing URL and store state for trace IDs
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3714 +/- ##
=======================================
Coverage 89.21% 89.21%
=======================================
Files 330 330
Lines 9900 9900
Branches 2570 2572 +2
=======================================
Hits 8832 8832
Misses 926 926
Partials 142 142 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Which problem is this PR solving?
/trace/...(the compare URL with no trace IDs filled in) showed a blank page.Root cause
Two values that both mean "no trace selected" were compared with strict
equality in
syncStates:aandbasnullundefinedwhen a trace ID segment is emptyundefined !== nullistrue, sosyncStatescalledforceStateon every render.forceStatewrotenullback to the store, which triggered a re-render, which re-ran the effect, which calledforceStateagain - infinitely.In Console:

Before:

After:

How was this change tested?
Checklist
make lint testAI Usage in this PR (choose one)
See AI Usage Policy.