Skip to content

Comments

Fix infinite re-render loop in useAppsAlert causing crash#6364

Merged
lkostrowski merged 1 commit intomainfrom
fix-inifnite-loops
Feb 24, 2026
Merged

Fix infinite re-render loop in useAppsAlert causing crash#6364
lkostrowski merged 1 commit intomainfrom
fix-inifnite-loops

Conversation

@lkostrowski
Copy link
Member

Wrap callback functions in useCallback to stabilize references:

  • handleFetchAppsWebhooks in useAppsFailedDeliveries
  • handleClick and handleFailedAttempt in useSidebarDotState
  • persist in useSidebarWebhookAlertMetadata

Without stable references, these functions created new identities on every render, causing useEffect/useCallback deps in useAppsAlert to trigger continuously — firing GraphQL queries and mutations in an infinite loop on every page load.

Scope of the change

  • I confirm I added ripples for changes (see src/ripples) or my feature doesn't contain any user-facing changes
  • I used analytics "trackEvent" for important events

Wrap callback functions in useCallback to stabilize references:
- handleFetchAppsWebhooks in useAppsFailedDeliveries
- handleClick and handleFailedAttempt in useSidebarDotState
- persist in useSidebarWebhookAlertMetadata

Without stable references, these functions created new identities on
every render, causing useEffect/useCallback deps in useAppsAlert to
trigger continuously — firing GraphQL queries and mutations in an
infinite loop on every page load.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 24, 2026 13:35
@lkostrowski lkostrowski requested a review from a team as a code owner February 24, 2026 13:35
@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2026

⚠️ No Changeset found

Latest commit: f1fc9a3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@lkostrowski lkostrowski changed the title Fix infinite re-render loop in useAppsAlert causing CPU/RAM spike Fix infinite re-render loop in useAppsAlert causing crash Feb 24, 2026
@lkostrowski lkostrowski added skip changeset Use if your changes doesn't need entry in changelog test deployment Deploy Pull Request to *.saleor.rocks environment labels Feb 24, 2026
Copy link
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 pull request fixes a critical performance issue where an infinite re-render loop was causing CPU and RAM spikes on every page load. The root cause was unstable function references in the AppAlerts hook chain that triggered continuous re-renders, repeatedly firing GraphQL queries and mutations.

Changes:

  • Wrapped callback functions with useCallback to stabilize their references across renders
  • Added proper dependency arrays to ensure callbacks only change when their dependencies change
  • Prevented the infinite loop caused by unstable function references in useEffect dependency arrays

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/extensions/components/AppAlerts/useSidebarWebhookAlertMetadata.ts Wrapped persist function with useCallback and [saveMetadata] dependency to stabilize its reference
src/extensions/components/AppAlerts/useSidebarDotState.ts Wrapped handleClick and handleFailedAttempt functions with useCallback and [persist] dependency to stabilize their references
src/extensions/components/AppAlerts/useAppsFailedDeliveries.ts Wrapped handleFetchAppsWebhooks function with useCallback and [fetchAppsWebhooks] dependency to stabilize its reference

@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.72%. Comparing base (fca0cbf) to head (f1fc9a3).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ensions/components/AppAlerts/useSidebarDotState.ts 88.23% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6364   +/-   ##
=======================================
  Coverage   42.71%   42.72%           
=======================================
  Files        2534     2534           
  Lines       44006    44009    +3     
  Branches    10417    10434   +17     
=======================================
+ Hits        18799    18802    +3     
  Misses      23868    23868           
  Partials     1339     1339           

☔ 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.

@lkostrowski lkostrowski merged commit 8e94181 into main Feb 24, 2026
35 of 37 checks passed
@lkostrowski lkostrowski deleted the fix-inifnite-loops branch February 24, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changeset Use if your changes doesn't need entry in changelog test deployment Deploy Pull Request to *.saleor.rocks environment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants