From 00bc27fe023a39cdc63e522a45cd3ba717b571e7 Mon Sep 17 00:00:00 2001 From: Nick Peihl Date: Mon, 4 Aug 2025 15:21:20 -0400 Subject: [PATCH] [Dashboard] Remove unncessary promises (#230313) ## Summary Removes unnecessary promises in DashboardStorage class. All of the functions are synchronous so we don't need to await or wrap in Promise.all. (cherry picked from commit edb3fa8fcf8ec473e061a90305e9f222ecaa2715) --- .../content_management/dashboard_storage.ts | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/platform/plugins/shared/dashboard/server/content_management/dashboard_storage.ts b/src/platform/plugins/shared/dashboard/server/content_management/dashboard_storage.ts index 9ba230ffd5bc7..5201d0e900514 100644 --- a/src/platform/plugins/shared/dashboard/server/content_management/dashboard_storage.ts +++ b/src/platform/plugins/shared/dashboard/server/content_management/dashboard_storage.ts @@ -426,20 +426,18 @@ export class DashboardStorage { const soQuery = searchArgsToSOFindOptions(query, optionsToLatest); // Execute the query in the DB const soResponse = await soClient.find(soQuery); - const hits = await Promise.all( - soResponse.saved_objects - .map(async (so) => { - const { item } = savedObjectToItem(so, false, { - allowedAttributes: soQuery.fields, - allowedReferences: optionsToLatest?.includeReferences, - getTagNamesFromReferences: (references: SavedObjectReference[]) => - this.getTagNamesFromReferences(references, allTags), - }); - return item; - }) - // Ignore any saved objects that failed to convert to items. - .filter((item) => item !== null) - ); + const hits = soResponse.saved_objects + .map((so) => { + const { item } = savedObjectToItem(so, false, { + allowedAttributes: soQuery.fields, + allowedReferences: optionsToLatest?.includeReferences, + getTagNamesFromReferences: (references: SavedObjectReference[]) => + this.getTagNamesFromReferences(references, allTags), + }); + return item; + }) + // Ignore any saved objects that failed to convert to items. + .filter((item) => item !== null); const response = { hits, pagination: {