Skip to content

Commit

Permalink
fix: broken impl and race condition in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coroiu committed Oct 16, 2024
1 parent 6b7b016 commit 85d4809
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
Expand Down
7 changes: 3 additions & 4 deletions libs/common/src/platform/services/sdk/default-sdk.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,9 @@ export class DefaultSdkService implements SdkService {
return new Observable<BitwardenClient>((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);
Expand All @@ -107,7 +106,7 @@ export class DefaultSdkService implements SdkService {
await this.initializeClient(client, account, kdfParams, privateKey, userKey, orgKeys);

return client;
}
};

createAndInitializeClient()
.then((c) => {
Expand Down

0 comments on commit 85d4809

Please sign in to comment.