Skip to content

feat: add EventQueue class util to guarantee the order of user-storage updates #5937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mathieuartu
Copy link
Contributor

@mathieuartu mathieuartu commented Jun 6, 2025

Explanation

This PR add a new EventQueue shared class util to the @metamask/profile-sync-controller package.
We are using this to ensure user-storage updates are executed and fulfilled in the actual order they were called.
For now, this is used for account syncing when reacting to AccountsController accountRenamed and accountAdded events.

This addition has been made in reaction to a recent change to extension code that made it so that when a user adds a new account, without changing the default name, both accountAdded and accountRenamed were fired.
This induced race conditions where we weren't in control of which user-storage request would land first.
With this change, we raise back our confidence to 100%.

References

Changelog

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@mathieuartu mathieuartu self-assigned this Jun 6, 2025
@mathieuartu mathieuartu added the team-identity Identity Team changes. https://github.com/orgs/MetaMask/teams/identity label Jun 6, 2025
@mathieuartu mathieuartu marked this pull request as ready for review June 6, 2025 17:05
@mathieuartu mathieuartu requested review from a team as code owners June 6, 2025 17:05
@mathieuartu mathieuartu changed the title feat: add EventQueue class to guarantee sequential user-storage updates feat: add EventQueue class util to guarantee the order of user-storage updates Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-identity Identity Team changes. https://github.com/orgs/MetaMask/teams/identity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant