From 6199e585326949120350e396ab5bce64d64aba18 Mon Sep 17 00:00:00 2001 From: Lemon Date: Sat, 16 Dec 2023 02:13:29 +0800 Subject: [PATCH] fix: list items lock race (#7133) Co-authored-by: Tom <144813356+ttalty@users.noreply.github.com> --- apps/cli/src/commands/list.command.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/cli/src/commands/list.command.ts b/apps/cli/src/commands/list.command.ts index fbb0dd08e0..63ec13a8c9 100644 --- a/apps/cli/src/commands/list.command.ts +++ b/apps/cli/src/commands/list.command.ts @@ -126,16 +126,17 @@ export class ListCommand { ciphers = this.searchService.searchCiphersBasic(ciphers, options.search, options.trash); } - ciphers.forEach((c, index) => { + for (let i = 0; i < ciphers.length; i++) { + const c = ciphers[i]; // Set upload immediately on the last item in the ciphers collection to avoid the event collection // service from uploading each time. - this.eventCollectionService.collect( + await this.eventCollectionService.collect( EventType.Cipher_ClientViewed, c.id, - index === ciphers.length - 1, + i === ciphers.length - 1, c.organizationId, ); - }); + } const res = new ListResponse(ciphers.map((o) => new CipherResponse(o))); return Response.success(res);