Skip to content

fix: prevent infinite loop on TraceDiff with empty trace IDs#3714

Merged
yurishkuro merged 1 commit intojaegertracing:mainfrom
Parship12:compare-screen-bug
Apr 9, 2026
Merged

fix: prevent infinite loop on TraceDiff with empty trace IDs#3714
yurishkuro merged 1 commit intojaegertracing:mainfrom
Parship12:compare-screen-bug

Conversation

@Parship12
Copy link
Copy Markdown
Member

Which problem is this PR solving?

  • Navigating to /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:

  • The Zustand store initializes a and b as null
  • URL parsing produces undefined when a trace ID segment is empty undefined !== null is true, so syncStates called forceState on every render. forceState wrote null back to the store, which triggered a re-render, which re-ran the effect, which called forceState again - infinitely.

In Console:
Screenshot 2026-04-09 104923

Before:
Screenshot 2026-04-09 105201

After:
Screenshot 2026-04-09 105221

How was this change tested?

  • Unit testing
  • Compare page working properly

Checklist

AI Usage in this PR (choose one)

See AI Usage Policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

Signed-off-by: Parship Chowdhury <parshipchowdhury@gmail.com>
@Parship12 Parship12 requested a review from a team as a code owner April 9, 2026 05:23
Copilot AI review requested due to automatic review settings April 9, 2026 05:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 syncStates function to normalize undefined and null values when comparing URL and store state for trace IDs

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.21%. Comparing base (f9226f8) to head (f534e73).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yurishkuro yurishkuro added the changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements label Apr 9, 2026
@yurishkuro yurishkuro merged commit 6f319e2 into jaegertracing:main Apr 9, 2026
16 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants