Skip to content

[PM-43127] fix(vault): share in-flight profile fetch to avoid duplicate profile requests - #23023

Open
Tyagiquamar wants to merge 1 commit into
bitwarden:mainfrom
Tyagiquamar:fix/vault-profile-inflight-dedupe
Open

[PM-43127] fix(vault): share in-flight profile fetch to avoid duplicate profile requests#23023
Tyagiquamar wants to merge 1 commit into
bitwarden:mainfrom
Tyagiquamar:fix/vault-profile-inflight-dedupe

Conversation

@Tyagiquamar

Copy link
Copy Markdown

Fixes #22840

Problem

Two nudge services (account-security-nudge.service.ts, new-account-nudge.service.ts) each call VaultProfileService.getProfileCreationDate() during popup init. fetchAndCacheProfile() only caches after the request resolves, so both concurrent calls miss the cache and independently fire GET /accounts/profile — two identical requests on every popup open (traced in the issue).

Fix

Deduplicate concurrent fetches with a shared in-flight promise in fetchAndCacheProfile() — the same pattern DefaultSyncService already uses for sync/refreshToken. The promise is cleared in finally once settled, so a subsequent call after an error or completion re-fetches exactly as before. Behavior for sequential calls is unchanged.

Validation

  • npx jest libs/angular/src/vault/services/vault-profile.service.spec.ts — 4 passed, including a new test:
    • shares one in-flight getProfile call between concurrent callers — two concurrent getProfileCreationDate calls while the API call is still pending result in exactly one getProfile invocation; fails on main (2 calls), passes with this fix
    • all 3 pre-existing tests unchanged and green

…requests

Concurrent callers of getProfileCreationDate (the account-security and
new-account nudge services during popup init) each resolved before the
cache was populated and independently called apiService.getProfile(),
producing two identical GET /accounts/profile requests on every popup
open. fetchAndCacheProfile now shares a single in-flight promise,
clearing it once settled so later calls re-fetch as before.

Fixes bitwarden#22840
@Tyagiquamar
Tyagiquamar requested a review from a team as a code owner September 5, 2026 14:42
@CLAassistant

CLAassistant commented Sep 5, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@bitwarden-bot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! We've added this to our internal tracking system for review.
ID: PM-43127
Link: https://bitwarden.atlassian.net/browse/PM-43127

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@bitwarden-bot bitwarden-bot changed the title fix(vault): share in-flight profile fetch to avoid duplicate profile requests [PM-43127] fix(vault): share in-flight profile fetch to avoid duplicate profile requests Sep 5, 2026
@bitwarden-bot bitwarden-bot added community-pr needs-qa Marks a PR as requiring QA approval labels Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-pr needs-qa Marks a PR as requiring QA approval

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate, non-deduped GET /accounts/profile calls on every popup open (MV3)

3 participants