fix(profile-sync-controller): deduplicate identical pairing calls#8984
Merged
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
ccharly
reviewed
Jun 4, 2026
|
|
||
| await auth.pairSrpProfiles(['a', 'b'], 'a'); | ||
| // Advance beyond the 30s dedupe window. | ||
| jest.setSystemTime(Date.now() + 30_001); |
Contributor
There was a problem hiding this comment.
WDYT about exporting PAIR_DEDUPE_TTL_MS and use PAIR_DEDUPE_TTL_MS + 1 here?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
References
Related to: https://consensyssoftware.atlassian.net/browse/MUL-1865
Checklist
Note
Low Risk
Localized SDK caching around pairing; failures are not cached, preserving existing retry behavior with reduced duplicate traffic.
Overview
SRPJwtBearerAuth.pairSrpProfilesno longer fires a separatePOST /api/v2/profile/pairfor every overlapping caller. It now keys an in-memory cache by the sorted access-token set (order-insensitive), merges concurrent calls on one in-flight promise, and reuses a successful response for 30s (PAIR_DEDUPE_TTL_MS). Failed pair attempts are not cached soneedsProfilePairingretries still hit the API.Changelog and unit tests cover concurrent/sequential dedupe, token-order equivalence, TTL expiry, failure retry, and distinct token sets.
Reviewed by Cursor Bugbot for commit c792f2b. Bugbot is set up for automated code reviews on this repo. Configure here.