GitAuto: A performance of a page (/settings/integrations/jira) is too slow. #138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #133
Why the bug occurs
The
/settings/integrations/jira
page is experiencing performance issues because the APIs/api/jira/get-projects
and/api/github/get-installed-repos
are being called multiple times. Specifically, both APIs are invoked twice in quick succession, leading to redundant network requests and slowing down the page load time.How to reproduce
/settings/integrations/jira
page./api/jira/get-projects
endpoint is called twice in a row./api/github/get-installed-repos
endpoint is also called twice.How to fix
Debounce API Calls: Ensure that the API calls to
/api/jira/get-projects
and/api/github/get-installed-repos
are not triggered multiple times unnecessarily. Implement debounce mechanisms to limit the frequency of these calls.Optimize Component Rendering: Investigate if the components responsible for these API calls are re-rendering more often than necessary. Utilize techniques like
React.memo
oruseMemo
to prevent unnecessary re-renders.Consolidate API Requests: If possible, combine multiple API requests into a single call to reduce the number of network requests.
Review UseEffect Dependencies: Ensure that the dependencies in
useEffect
hooks (if using React) are correctly set to prevent repeated executions of the API calls.Implementing these changes should reduce the number of redundant API calls, thereby improving the page's performance.
Test these changes locally