Skip to content

Conversation

marcotoniut-ledger
Copy link
Contributor

@marcotoniut-ledger marcotoniut-ledger commented Aug 12, 2025

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • Some changes in how anonymous notifications are purged when tracking stops.
    • Prevents unnecessary renders and API calls.
    • Reduces CPU usage and resolves the infinite loop.
    • Keeps purge behaviour intact for stale notifications.

📝 Description

This PR addresses an infinite loop issue observed in PROD-11430, where CLEAR_DISMISSED_CONTENT_CARDS and updateAnonymousUserNotifications were repeatedly dispatched, causing extreme CPU usage and UI lag.

The issue occurs for untracked users when anonymousUserNotifications contains a mix of expired and valid entries during initialisation. The purge logic in useBraze partially removes expired items but still generates a new object reference on every run. Because this updated object is part of the initBraze dependency array, it continuously re-triggers initBraze, causing repeated Braze re-initialisations and excessive API calls.

Fix:

  • Updated purge logic to only create a new anonymousUserNotifications object when changes are detected.
  • Ensured cleanup converges to a stable state after the first pass to prevent repeated triggers.
  • Maintained existing behaviour for tracked users and normal content card updates.

❓ Context


🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

@marcotoniut-ledger marcotoniut-ledger requested a review from a team as a code owner August 12, 2025 20:59
Copy link

vercel bot commented Aug 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Project Deployment Preview Comments Updated (UTC)
web-tools Failed Aug 13, 2025 9:01am
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
ledger-live-github-bot ⬜️ Ignored Preview Aug 13, 2025 9:01am
native-ui-storybook ⬜️ Ignored Preview Aug 13, 2025 9:01am
react-ui-storybook ⬜️ Ignored Preview Aug 13, 2025 9:01am

@live-github-bot live-github-bot bot added desktop Has changes in LLD common Has changes in live-common labels Aug 12, 2025
@marcotoniut-ledger marcotoniut-ledger force-pushed the LIVE-20867-ledger-live-wont-load-or-is-extremely-laggy-on-mac-windows branch from f67f331 to 15c776d Compare August 12, 2025 21:10
@marcotoniut-ledger marcotoniut-ledger force-pushed the LIVE-20867-ledger-live-wont-load-or-is-extremely-laggy-on-mac-windows branch from b0efb94 to 43182d9 Compare August 13, 2025 08:59
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
43.2% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)
4 New Code Smells (required ≤ 1)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@marcotoniut-ledger marcotoniut-ledger merged commit cab707b into develop Aug 13, 2025
68 of 70 checks passed
@marcotoniut-ledger marcotoniut-ledger deleted the LIVE-20867-ledger-live-wont-load-or-is-extremely-laggy-on-mac-windows branch August 13, 2025 20:11
marcotoniut-ledger added a commit that referenced this pull request Aug 14, 2025
…oad-or-is-extremely-laggy-on-mac-windows

LIVE-20867: prevent infinite rendering cycles when purging anonymous notifications
(cherry picked from commit cab707b)
Copy link

sentry-io bot commented Aug 16, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

marcotoniut-ledger added a commit that referenced this pull request Aug 19, 2025
…oad-or-is-extremely-laggy-on-mac-windows

LIVE-20867: prevent infinite rendering cycles when purging anonymous notifications
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
common Has changes in live-common desktop Has changes in LLD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants