-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[DataViews] Fix checking remote clusters in empty state #110054
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -69,7 +69,6 @@ const IndexPatternEditorFlyoutContentComponent = ({ | |
| defaultTypeIsRollup, | ||
| requireTimestampField = false, | ||
| }: Props) => { | ||
| const isMounted = useRef<boolean>(false); | ||
| const { | ||
| services: { http, indexPatternService, uiSettings, searchClient }, | ||
| } = useKibana<IndexPatternEditorContext>(); | ||
|
|
@@ -156,30 +155,23 @@ const IndexPatternEditorFlyoutContentComponent = ({ | |
|
|
||
| // loading list of index patterns | ||
| useEffect(() => { | ||
| isMounted.current = true; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (not related to the main fix, but way too minor to extract to separate pr) I noticed that how this Instead of fixing it, I removed it. (no need for it because no race condition or potential memory leaks here) see: |
||
| loadSources(); | ||
| const getTitles = async () => { | ||
| const indexPatternTitles = await indexPatternService.getTitles(); | ||
| if (isMounted.current) { | ||
| setExistingIndexPatterns(indexPatternTitles); | ||
| setIsLoadingIndexPatterns(false); | ||
| } | ||
|
|
||
| setExistingIndexPatterns(indexPatternTitles); | ||
| setIsLoadingIndexPatterns(false); | ||
| }; | ||
| getTitles(); | ||
| return () => { | ||
| isMounted.current = false; | ||
| }; | ||
| }, [http, indexPatternService, loadSources]); | ||
|
|
||
| // loading rollup info | ||
| useEffect(() => { | ||
| const getRollups = async () => { | ||
| try { | ||
| const response = await http.get('/api/rollup/indices'); | ||
| if (isMounted.current) { | ||
| if (response) { | ||
| setRollupIndicesCapabilities(response); | ||
| } | ||
| if (response) { | ||
| setRollupIndicesCapabilities(response); | ||
| } | ||
| } catch (e) { | ||
| // Silently swallow failure responses such as expired trials | ||
|
|
@@ -214,10 +206,7 @@ const IndexPatternEditorFlyoutContentComponent = ({ | |
| ); | ||
| timestampOptions = extractTimeFields(fields, requireTimestampField); | ||
| } | ||
| if ( | ||
| isMounted.current && | ||
| currentLoadingTimestampFieldsIdx === currentLoadingTimestampFieldsRef.current | ||
| ) { | ||
| if (currentLoadingTimestampFieldsIdx === currentLoadingTimestampFieldsRef.current) { | ||
| setIsLoadingTimestampFields(false); | ||
| setTimestampFieldOptions(timestampOptions); | ||
| } | ||
|
|
@@ -266,10 +255,7 @@ const IndexPatternEditorFlyoutContentComponent = ({ | |
| exactMatched: [], | ||
| }; | ||
|
|
||
| if ( | ||
| currentLoadingMatchedIndicesIdx === currentLoadingMatchedIndicesRef.current && | ||
| isMounted.current | ||
| ) { | ||
| if (currentLoadingMatchedIndicesIdx === currentLoadingMatchedIndicesRef.current) { | ||
| // we are still interested in this result | ||
| if (type === INDEX_PATTERN_TYPE.ROLLUP) { | ||
| const rollupIndices = exactMatched.filter((index) => isRollupIndex(index.name)); | ||
|
|
@@ -291,10 +277,6 @@ const IndexPatternEditorFlyoutContentComponent = ({ | |
| [http, allowHidden, allSources, type, rollupIndicesCapabilities, searchClient, isLoadingSources] | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| reloadMatchedIndices(title); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sebelga pointed out that this might be redundant: #109500 (comment) (not related to the main fix, but way too minor to extract to separate pr)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 I'd expect the number of requests to go from 3 to 2 (without the |
||
| }, [allowHidden, reloadMatchedIndices, title]); | ||
|
|
||
| const onTypeChange = useCallback( | ||
| (newType) => { | ||
| form.setFieldValue('title', ''); | ||
|
|
||
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.
This is the main fix
[DataViews] Fix checking remote clusters in empty stateWe had
useCallbackinstead ofuseEffectby mistake