[8.8] [Logs UI] Fix Log Categorization UI failure due to infinite loop (#159090) (#159106)

# Backport

Closes #158930 

This will backport the following commits from `main` to `8.8`:
- [[Logs UI] Fix Log Categorization UI failure due to infinite loop
(#159090)](https://github.com/elastic/kibana/pull/159090)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco Antonio
Ghiani","email":"marcoantonio.ghiani01@gmail.com"},"sourceCommit":{"committedDate":"2023-06-06T11:31:03Z","message":"[Logs
UI] Fix Log Categorization UI failure due to infinite loop
(#159090)\n\n## 📓 Summary\r\n\r\nWith the usage of the
`logViewReference` object (instead of the\r\nprimitive `sourceId`) as a
dependency for the log entries categories\r\ndata fetching, the
`useTrackedPromise` was continuously recreating
the\r\n`getLogEntryCategoryDatasets` and `getTopLogEntryCategories`
fetchers,\r\nwhich were consequently causing an infinite loop when
called inside the\r\nrelated side effect and used as
dependency.\r\n\r\nUsing the `logViewReference.logViewId` property
(equivalent to the\r\nlegacy `sourceId` string) restores the expected
behaviour.\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>","sha":"d6105d0bfe0634a0543e52ce3c1275ad0bd64250","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Feature:Logs
UI","Team:Infra Monitoring
UI","backport:prev-minor","v8.9.0"],"number":159090,"url":"https://github.com/elastic/kibana/pull/159090","mergeCommit":{"message":"[Logs
UI] Fix Log Categorization UI failure due to infinite loop
(#159090)\n\n## 📓 Summary\r\n\r\nWith the usage of the
`logViewReference` object (instead of the\r\nprimitive `sourceId`) as a
dependency for the log entries categories\r\ndata fetching, the
`useTrackedPromise` was continuously recreating
the\r\n`getLogEntryCategoryDatasets` and `getTopLogEntryCategories`
fetchers,\r\nwhich were consequently causing an infinite loop when
called inside the\r\nrelated side effect and used as
dependency.\r\n\r\nUsing the `logViewReference.logViewId` property
(equivalent to the\r\nlegacy `sourceId` string) restores the expected
behaviour.\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>","sha":"d6105d0bfe0634a0543e52ce3c1275ad0bd64250"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/159090","number":159090,"mergeCommit":{"message":"[Logs
UI] Fix Log Categorization UI failure due to infinite loop
(#159090)\n\n## 📓 Summary\r\n\r\nWith the usage of the
`logViewReference` object (instead of the\r\nprimitive `sourceId`) as a
dependency for the log entries categories\r\ndata fetching, the
`useTrackedPromise` was continuously recreating
the\r\n`getLogEntryCategoryDatasets` and `getTopLogEntryCategories`
fetchers,\r\nwhich were consequently causing an infinite loop when
called inside the\r\nrelated side effect and used as
dependency.\r\n\r\nUsing the `logViewReference.logViewId` property
(equivalent to the\r\nlegacy `sourceId` string) restores the expected
behaviour.\r\n\r\nCo-authored-by: Marco Antonio Ghiani
<marcoantonio.ghiani@elastic.co>","sha":"d6105d0bfe0634a0543e52ce3c1275ad0bd64250"}}]}]
BACKPORT-->

Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani01@gmail.com>
This commit is contained in:
Kibana Machine 2023-06-06 08:45:24 -04:00 committed by GitHub
parent 71b9212811
commit e280aa0041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -80,7 +80,7 @@ export const useLogEntryCategoriesResults = ({
}
},
},
[categoriesCount, endTime, filteredDatasets, logViewReference, startTime, sortOptions]
[categoriesCount, endTime, filteredDatasets, logViewReference.logViewId, startTime, sortOptions]
);
const [getLogEntryCategoryDatasetsRequest, getLogEntryCategoryDatasets] = useTrackedPromise(
@ -105,7 +105,7 @@ export const useLogEntryCategoriesResults = ({
}
},
},
[categoriesCount, endTime, logViewReference, startTime]
[categoriesCount, endTime, logViewReference.logViewId, startTime]
);
const isLoadingTopLogEntryCategories = useMemo(