From e770e358b5e012ad2249b68315fef48f551fabee Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Mon, 15 Jan 2024 16:08:24 +0100 Subject: [PATCH] Make sure we're not creating a saved search while a previous creation call is in progress --- .../use_discover_in_timeline_actions.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/common/components/discover_in_timeline/use_discover_in_timeline_actions.tsx b/x-pack/plugins/security_solution/public/common/components/discover_in_timeline/use_discover_in_timeline_actions.tsx index 47c1d8b478c2d..e13788b8f7f07 100644 --- a/x-pack/plugins/security_solution/public/common/components/discover_in_timeline/use_discover_in_timeline_actions.tsx +++ b/x-pack/plugins/security_solution/public/common/components/discover_in_timeline/use_discover_in_timeline_actions.tsx @@ -205,6 +205,10 @@ export const useDiscoverInTimelineActions = ( } else { // If no saved search exists. Create a new saved search instance and associate it with the timeline. try { + // Make sure we're not creating a saved search while a previous creation call is in progress + if (status !== 'idle') { + return; + } dispatch( timelineActions.startTimelineSaving({ id: TimelineId.active, @@ -218,7 +222,7 @@ export const useDiscoverInTimelineActions = ( const responseIsEmpty = !response || !response?.id; if (responseIsEmpty) { throw new Error('Response is empty'); - } else if (!savedSearchId && !responseIsEmpty && status !== 'loading') { + } else if (!savedSearchId && !responseIsEmpty) { dispatch( timelineActions.updateSavedSearchId({ id: TimelineId.active,