Skip to content

Commit fedc630

Browse files
Addressing feedback
1 parent 46699bd commit fedc630

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

x-pack/plugins/security_solution/public/app/home/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ const HomePageComponent: React.FC<HomePageProps> = ({ children }) => {
6060

6161
const { browserFields, indexPattern, indicesExist } = useSourcererScope();
6262
// side effect: this will attempt to upgrade the endpoint package if it is not up to date
63+
// this will run when a user navigates to the Security Solution app and when they navigate between
64+
// tabs in the app. This is useful for keeping the endpoint package as up to date as possible until
65+
// a background task solution can be built on the server side. Once a background task solution is available we
66+
// can remove this.
6367
useUpgradeEndpointPackage();
6468

6569
return (

x-pack/plugins/security_solution/public/common/hooks/endpoint/upgrade.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const useUpgradeEndpointPackage = () => {
5757
const abortController = new AbortController();
5858

5959
// cancel any ongoing requests
60-
const cleanup = () => {
60+
const abortRequests = () => {
6161
abortController.abort();
6262
};
6363

@@ -73,18 +73,22 @@ export const useUpgradeEndpointPackage = () => {
7373

7474
// if we're not a privileged user then return and don't try to check the status of the endpoint package
7575
if (!hasPermissions) {
76-
return cleanup;
76+
return abortRequests;
7777
}
7878

7979
// ignore the response for now since we aren't notifying the user
8080
await sendUpgradeEndpointPackage(context.services.http, { signal });
8181
} catch (error) {
8282
// Ignore Errors, since this should not hinder the user's ability to use the UI
83-
// eslint-disable-next-line no-console
84-
console.error(error);
83+
84+
// ignore the error that occurs from aborting a request
85+
if (!abortController.signal.aborted) {
86+
// eslint-disable-next-line no-console
87+
console.error(error);
88+
}
8589
}
8690

87-
return cleanup;
91+
return abortRequests;
8892
})();
8993
}
9094
}, [ingestEnabled, context.services.http]);

0 commit comments

Comments
 (0)