-
Notifications
You must be signed in to change notification settings - Fork 18
Fix detector list infinite loading on cluster initialization #177
Fix detector list infinite loading on cluster initialization #177
Conversation
dispatch(getDetectorList(GET_ALL_DETECTORS_QUERY_PARAMS)); | ||
const getUpdatedDetectors = async () => { | ||
try { | ||
await dispatch(getDetectorList(GET_ALL_DETECTORS_QUERY_PARAMS)); | ||
} catch (error) { | ||
console.log('Error is found during getting detector list', error); | ||
setIsLoadingFinalDetectors(false); | ||
} | ||
}; |
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 only change; the other changes are auto-formatting changes. Somehow my local dev environment stopped auto-formatting on save at some point, fixed it now.
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.
LGTM. Thanks for the fix.
await dispatch(getDetectorList(GET_ALL_DETECTORS_QUERY_PARAMS)); | ||
} catch (error) { | ||
console.log('Error is found during getting detector list', error); | ||
setIsLoadingFinalDetectors(false); |
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.
should we movesetIsLoadingFinalDetectors(false);
to finally
? looks like only when exception is caught, isLoading
can be set to false
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.
That's the behavior I want here. It should only be set to false if there was an error. If successful and the detectors are retrieved, it should be set to true until the final set of sorted detectors to display are finished here.
Note that isLoadingFinalDetectors
is only related to sorting/filtering in the frontend. isRequestingFromES
handles loading from the backend.
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.
Got it.
Issue #, if available: #176
Description of changes:
On cluster initialization (when .opendistro-anomaly-detectors index doesn't exist yet) there is an uncaught exception on the detector list page if a user tries changing any filters / searching / sorting etc., leaving the page in an infinite loading state.
This fixes that by fixing the error handling when making the backend call.
Before:
After:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.