From 842fa5153b9bdeadbb14e3c632fe3f31a9a02982 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 24 Jan 2024 19:42:37 +0100 Subject: [PATCH] Replace promise.all with for loop for performance reasons (#7582) --- .../cryptography/encrypt.service.implementation.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/common/src/platform/services/cryptography/encrypt.service.implementation.ts b/libs/common/src/platform/services/cryptography/encrypt.service.implementation.ts index b61f44fa3c..4829c297f0 100644 --- a/libs/common/src/platform/services/cryptography/encrypt.service.implementation.ts +++ b/libs/common/src/platform/services/cryptography/encrypt.service.implementation.ts @@ -155,7 +155,12 @@ export class EncryptServiceImplementation implements EncryptService { return []; } - return await Promise.all(items.map((item) => item.decrypt(key))); + // don't use promise.all because this task is not io bound + let results = []; + for (let i = 0; i < items.length; i++) { + results.push(await items[i].decrypt(key)); + } + return results; } async hash(value: string | Uint8Array, algorithm: "sha1" | "sha256" | "sha512"): Promise {