-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SecuritySoltuon] fix unnecessary requests from the alert flyout #196521
[SecuritySoltuon] fix unnecessary requests from the alert flyout #196521
Conversation
This removed 3 (!!!) global route rerenders
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
|
Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations) |
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 was a great find!
Security solution's ReactQuery client comes with some defaults that make sure that unnecessary requests due to focus changes don't occur.
Do you mean setting refetchOnWindowFocus: false
? I wonder if we have similar behavior somewhere in cases 🤔
I'll look into updating it in x-pack/plugins/cases/public/components/cases_context/query_client.ts
Yep, that's the one :) |
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.
Sorry @janmonschke I had a chat with the team about this PR and having some concerns we decided to block the PR for now 😅
We are worried about unexpected side effects of replacing the cases query client and will have a chat about it tomorrow. I'll get back to you.
@adcoelho Understood, looking forward to your conclusion. Since you're talking about being worried about side effects for cases, not fixing this, will have side effects for everywhere else cases are used ;) A quick fix would be to add the same defaults to cases but then we might have problems further down the line when the defaults are changed in either place. Zooming out, this is not just an issue in cases <-> security solution, but an overall issue whenever plugins/packages etc use a |
Well, yes and no. That specific setting exists for a reason, and its usage(or not) is not necessarily tied to unexpected consequences. What about the other side of the picture, where query data is stale?
We thought a more limited fix would rather allow this setting to be passed as props and used by cases when initializing their query client. We are also concerned with having multiple
Again, the query client is used in around 60-70 places but its initialization without the |
I see what you mean. Of course it's possible to not enable The requests that are repeated can be quite costly in certain scenarios and they are not even owned by us. I just stumbled over this by accident ;) I wonder if there's a better way to isolate the |
Btw, clicking from the DevTools to the page and vice-versa is considered a windows focus by React Query. Based on the video, it seems that annoyance is only when you use the DevTools (clicking from and to) and not something the users will experience. Could we verify that that's the case? |
@cnasikas Ahhhhh, good point, that's the case. I'll close the issue and the PR :) |
@janmonschke @cnasikas if it ever proves useful, there's a setting under the "Rendering" tool of chromium dev tools, 'emulate a focused page' which will prevent focus from leaving the page when interacting with devtools |
Summary
Fixes #195607
As described in the issue above, whenever a click was registered in the alert flyout, some logic in Kibana would trigger 5 HTTP requests.
After some debugging, it became apparent that it was caused by a misconfigured
ReactQuery
client stemming from the cases plugin. The cases client does not specify a behaviour for focus changes which was causing the extra HTTP requests.Security solution's
ReactQuery
client comes with some defaults that make sure that unnecessary requests due to focus changes don't occur. However, since the cases context was overriding theQueryClientProvider
, these defaults were overwritten.The fix was to add
queryClient
to theCaseContext
'svalue
.Checklist