-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security Solution] Fix paradigm around our container for search strategy query #90982
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
[Security Solution] Fix paradigm around our container for search strategy query #90982
Conversation
|
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
c97f0d1 to
fd53046
Compare
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! Some nit comments:
- For readability reasons I think
didCancel.current = false;is better to be along with
abortCtrl.current.abort();
asyncSearch();
refetch.current = asyncSearch;
after the declaration of the asyncSearch function. I think it makes more clear the order of the actions.
Example:
didCancel.current = false;
abortCtrl.current.abort();
asyncSearch();
refetch.current = asyncSearch;
-
Why we
setLoading(false);only if!(msg instanceof AbortError)? Shouldn't we do it on any error? If the user aborts the component will stuck on a loading state, right? -
What do you think about putting
searchSubscription$.unsubscribe();inside the clean-up function ofuseEffect?
Example:
return () => {
searchSubscription$.unsubscribe();
didCancel.current = true;
abortCtrl.current.abort();
};
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💔 Build Failed
Failed CI StepsTest FailuresKibana Pipeline / general / can be marked as favorite.Timelines Creates a timeline by clicking untitled timeline from bottom bar can be marked as favoriteStack TraceMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @XavierM |
…tegy query (elastic#90982) * fix paradigm around our serach strategy query * simplify logic to act with search strategy * miss to delete a declaration
…tegy query (elastic#90982) * fix paradigm around our serach strategy query * simplify logic to act with search strategy * miss to delete a declaration
…tegy query (elastic#90982) * fix paradigm around our serach strategy query * simplify logic to act with search strategy * miss to delete a declaration
…tegy query (#90982) (#92332) * fix paradigm around our serach strategy query * simplify logic to act with search strategy * miss to delete a declaration Co-authored-by: Xavier Mouligneau <[email protected]>
Summary
We found a problem around our paradigm in search strategy, the problem was that useCallback does not know when a component is going unmounted, however
useEffectdoes know all the secrets/ life cycle of a component therefore we are taking advantage of it. Also, in the mean time we did simplify our logic to useunsubscribemethod instead of usingdidCancel. We also had a bug that we did not setLoading to false when we get an error from our request.