From 5a6e51442d62ce69dab90d91a748e9755ffc7473 Mon Sep 17 00:00:00 2001 From: Nik Gilmore Date: Wed, 7 Jan 2026 17:17:01 -0800 Subject: [PATCH] Fix bug causing race condition due to not consuming / awaiting observable. --- libs/common/src/vault/services/cipher.service.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libs/common/src/vault/services/cipher.service.ts b/libs/common/src/vault/services/cipher.service.ts index 207c0c00b95..6bf82d7908b 100644 --- a/libs/common/src/vault/services/cipher.service.ts +++ b/libs/common/src/vault/services/cipher.service.ts @@ -910,9 +910,9 @@ export class CipherService implements CipherServiceAbstraction { userId: UserId, orgAdmin?: boolean, ): Promise { - const resultCipherView = firstValueFrom( + const resultCipherView = await firstValueFrom( this.sdkService.userClient$(userId).pipe( - map(async (sdk) => { + switchMap(async (sdk) => { if (!sdk) { throw new Error("SDK not available"); } @@ -927,7 +927,7 @@ export class CipherService implements CipherServiceAbstraction { return CipherView.fromSdkCipherView(result); }), catchError((error: unknown) => { - this.logService.error(`Failed to encrypt cipher: ${error}`); + this.logService.error(`Failed to create cipher: ${error}`); return EMPTY; }), ), @@ -988,9 +988,9 @@ export class CipherService implements CipherServiceAbstraction { originalCipherView?: CipherView, orgAdmin?: boolean, ): Promise { - const resultCipherView = firstValueFrom( + const resultCipherView = await firstValueFrom( this.sdkService.userClient$(userId).pipe( - map(async (sdk) => { + switchMap(async (sdk) => { if (!sdk) { throw new Error("SDK not available"); } @@ -1009,7 +1009,7 @@ export class CipherService implements CipherServiceAbstraction { return CipherView.fromSdkCipherView(result); }), catchError((error: unknown) => { - this.logService.error(`Failed to encrypt cipher: ${error}`); + this.logService.error(`Failed to update cipher: ${error}`); return EMPTY; }), ),