diff --git a/changelogs/fragments/8659.yml b/changelogs/fragments/8659.yml new file mode 100644 index 000000000000..7b007d454736 --- /dev/null +++ b/changelogs/fragments/8659.yml @@ -0,0 +1,2 @@ +fix: +- Discover UI stuck on searching after failing to find deleted index pattern ([#8659](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8659)) \ No newline at end of file diff --git a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts index 1ced2beaccfe..7274bf125497 100644 --- a/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts +++ b/src/plugins/discover/public/application/view_components/utils/use_index_pattern.ts @@ -74,25 +74,25 @@ export const useIndexPattern = (services: DiscoverViewServices) => { handleIndexPattern(); } } else { - try { - const ip = await fetchIndexPatternDetails(indexPatternIdFromState); - if (isMounted) { - setIndexPattern(ip); - } - } catch (error) { - if (isMounted) { - const warningMessage = i18n.translate('discover.indexPatternFetchErrorWarning', { - defaultMessage: 'Error fetching index pattern: {error}', - values: { error: (error as Error).message }, - }); - toastNotifications.addWarning(warningMessage); - } + const ip = await fetchIndexPatternDetails(indexPatternIdFromState); + if (isMounted) { + setIndexPattern(ip); } } } }; - handleIndexPattern(); + try { + handleIndexPattern(); + } catch (error) { + if (isMounted) { + const warningMessage = i18n.translate('discover.indexPatternFetchErrorWarning', { + defaultMessage: 'Error fetching index pattern: {error}', + values: { error: (error as Error).message }, + }); + toastNotifications.addWarning(warningMessage); + } + } return () => { isMounted = false;