-
Notifications
You must be signed in to change notification settings - Fork 667
CONSOLE-5035: cache lazy route components to prevent navigation freeze #15924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CONSOLE-5035: cache lazy route components to prevent navigation freeze #15924
Conversation
The LazyDynamicRoutePage component was calling React.lazy() inside a useMemo that depended on the component prop reference. During in-app navigation, if extension references changed, this caused: 1. React.lazy() to be called again, creating a new lazy component 2. React to unmount the old component and mount the new one 3. Suspense to trigger loading state and re-resolve the async import 4. Cascading re-mounts causing 100% CPU usage and page freeze Fix: Cache lazy components by extension UID in a module-level Map. The lazy component is created once per extension and reused on subsequent renders, preventing unnecessary remounting during navigation.
|
Skipping CI for Draft Pull Request. |
|
@logonoff: This pull request references CONSOLE-5035 which is a valid jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
WalkthroughThis change optimizes the plugin routing hook by introducing a memoized, per-extension lazy component cache keyed by extension UID. The refactor replaces a dynamic component wrapper approach with a cacheable lazy loader pattern while preserving existing activation/inactivation routing logic. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧹 Recent nitpick comments
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📒 Files selected for processing (1)
🔇 Additional comments (2)
✏️ Tip: You can disable this entire section by setting Comment |
|
/label px-approved /assign @yapei @vojtechszocs Note we can't really test this patch in a React 18 scenario at the moment, but we can verify that this doesn't cause problems in React 17 (e.g., |
|
@logonoff: This pull request references CONSOLE-5035 which is a valid jira issue. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
deploy |
|
@yapei: This PR has been marked as verified by DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
TheRealJon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
/retest |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logonoff, TheRealJon, vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@logonoff: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Cherrypick from #14869
The
LazyDynamicRoutePagecomponent was callingReact.lazy()inside auseMemothat depended on the component prop reference. During in-app navigation, if extension references changed, this caused:React.lazy()to be called again, creating a new lazy componentNow, we cache the resolved components by extension UID in a module-level Map. The lazy component is created once per extension and reused on subsequent renders, preventing unnecessary remounting during navigation.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.