diff --git a/libs/common/src/platform/services/sdk/default-sdk.service.spec.ts b/libs/common/src/platform/services/sdk/default-sdk.service.spec.ts index 9bbd04cda43..dad99401f75 100644 --- a/libs/common/src/platform/services/sdk/default-sdk.service.spec.ts +++ b/libs/common/src/platform/services/sdk/default-sdk.service.spec.ts @@ -122,9 +122,10 @@ describe("DefaultSdkService", () => { await new Promise(process.nextTick); userKey$.next(undefined); + await new Promise(process.nextTick); expect(mockClient.free).toHaveBeenCalledTimes(1); - expect(subject.value).toBeUndefined(); + expect(subject.value).toBe(undefined); }); }); }); diff --git a/libs/common/src/platform/services/sdk/default-sdk.service.ts b/libs/common/src/platform/services/sdk/default-sdk.service.ts index 5fcc4bf1111..1b7a9a939a4 100644 --- a/libs/common/src/platform/services/sdk/default-sdk.service.ts +++ b/libs/common/src/platform/services/sdk/default-sdk.service.ts @@ -95,10 +95,9 @@ export class DefaultSdkService implements SdkService { return new Observable((subscriber) => { let client: BitwardenClient; - async function createAndInitializeClient() { + const createAndInitializeClient = async () => { if (privateKey == null || userKey == null || orgKeys == null) { - subscriber.next(undefined); - return; + return undefined; } const settings = this.toSettings(env); @@ -107,7 +106,7 @@ export class DefaultSdkService implements SdkService { await this.initializeClient(client, account, kdfParams, privateKey, userKey, orgKeys); return client; - } + }; createAndInitializeClient() .then((c) => {