mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* fixes unhandled promise rejection when savedObject fails to find object with id * comments as to why / how / where this try-catch is needed
This commit is contained in:
parent
d0796bd5f5
commit
57083d4be1
1 changed files with 18 additions and 9 deletions
|
@ -157,15 +157,24 @@ export const QueryBarTimeline = memo<QueryBarTimelineComponentProps>(
|
|||
let isSubscribed = true;
|
||||
async function setSavedQueryByServices() {
|
||||
if (savedQueryId != null && savedQueryServices != null) {
|
||||
const mySavedQuery = await savedQueryServices.getSavedQuery(savedQueryId);
|
||||
if (isSubscribed) {
|
||||
setSavedQuery({
|
||||
...mySavedQuery,
|
||||
attributes: {
|
||||
...mySavedQuery.attributes,
|
||||
filters: filters.filter(f => f.meta.controlledBy !== timelineFilterDropArea),
|
||||
},
|
||||
});
|
||||
try {
|
||||
// The getSavedQuery function will throw a promise rejection in
|
||||
// src/legacy/core_plugins/data/public/search/search_bar/lib/saved_query_service.ts
|
||||
// if the savedObjectsClient is undefined. This is happening in a test
|
||||
// so I wrapped this in a try catch to keep the unhandled promise rejection
|
||||
// warning from appearing in tests.
|
||||
const mySavedQuery = await savedQueryServices.getSavedQuery(savedQueryId);
|
||||
if (isSubscribed && mySavedQuery != null) {
|
||||
setSavedQuery({
|
||||
...mySavedQuery,
|
||||
attributes: {
|
||||
...mySavedQuery.attributes,
|
||||
filters: filters.filter(f => f.meta.controlledBy !== timelineFilterDropArea),
|
||||
},
|
||||
});
|
||||
}
|
||||
} catch (exc) {
|
||||
setSavedQuery(null);
|
||||
}
|
||||
} else if (isSubscribed) {
|
||||
setSavedQuery(null);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue