From e04c528c3b09de273d99782e2bf2f956b6a3136f Mon Sep 17 00:00:00 2001 From: Aminejv Date: Thu, 19 Aug 2021 21:41:59 +0100 Subject: [PATCH] fix(viewer): use promise.allSettled instead of promise.all in the getById method --- node_common/managers/viewer.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/node_common/managers/viewer.js b/node_common/managers/viewer.js index ef800122..09e08a86 100644 --- a/node_common/managers/viewer.js +++ b/node_common/managers/viewer.js @@ -148,14 +148,16 @@ export const getById = async ({ id }) => { // user.library = await Data.getFilesByUserId({ id, sanitize: true }); - const [slates, keys, subscriptions, following, followers, { bucketRoot }] = await Promise.all([ - Data.getSlatesByUserId({ ownerId: id, sanitize: true, includeFiles: true }), - Data.getAPIKeysByUserId({ userId: id }), - Data.getSubscriptionsByUserId({ ownerId: id }), - Data.getFollowingByUserId({ ownerId: id }), - Data.getFollowersByUserId({ userId: id }), - Utilities.getBucketAPIFromUserToken({ user }), - ]); + const [slates, keys, subscriptions, following, followers, { bucketRoot }] = ( + await Promise.allSettled([ + Data.getSlatesByUserId({ ownerId: id, sanitize: true, includeFiles: true }), + Data.getAPIKeysByUserId({ userId: id }), + Data.getSubscriptionsByUserId({ ownerId: id }), + Data.getFollowingByUserId({ ownerId: id }), + Data.getFollowersByUserId({ userId: id }), + Utilities.getBucketAPIFromUserToken({ user }), + ]) + ).map((item) => item.value); const libraryCids = user?.library?.reduce((acc, file) => ({ ...acc, [file.cid]: file }), {}) || {};