Skip to content

fix(MUSD-402): resolve persisting mUSD success toast after rapid transaction confirmation#28040

Merged
shane-t merged 1 commit into
MetaMask:mainfrom
margelo:kureev/MUSD-402
Apr 13, 2026
Merged

fix(MUSD-402): resolve persisting mUSD success toast after rapid transaction confirmation#28040
shane-t merged 1 commit into
MetaMask:mainfrom
margelo:kureev/MUSD-402

Conversation

@Kureev

@Kureev Kureev commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a race condition in Toast.showToast where rapid successive calls (e.g., transaction approved + confirmed in the same tick on Linea) cause the success toast to persist indefinitely
  • Tracks pending setTimeout with a ref so only the latest showToast call wins, ensuring the success toast renders with its proper auto-dismiss animation
  • Adds test coverage for the rapid successive showToast scenario
Screen.Recording.2026-03-27.at.14.46.49.mov

Test plan

  • Toast unit tests pass (yarn jest app/component-library/components/Toast/Toast.test.tsx)
  • Manual: trigger a Max DAI→mUSD conversion on Linea and verify the success toast auto-dismisses after ~3s
  • Verify normal (non-rapid) toast transitions still work correctly

Note

Medium Risk
Touches toast display timing/animation logic; small but could regress toast sequencing or dismissal behavior if timer clearing interacts with existing transitions.

Overview
Fixes a race in Toast.showToast where back-to-back calls could leave multiple queued setTimeout updates, causing the wrong toast state/timeout behavior (e.g., a success toast persisting).

Toast now tracks and clears any pending setTimeout via a ref so only the latest showToast call applies. Adds a unit test asserting rapid successive calls leave a single pending timer and only the latest toast renders.

Written by Cursor Bugbot for commit 111df6d. This will update automatically on new commits. Configure here.

@Kureev Kureev requested a review from a team as a code owner March 27, 2026 13:49
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Comment thread app/component-library/components/Toast/Toast.test.tsx
@kirillzyusko

Copy link
Copy Markdown
Contributor

Hey @Kureev

I think we also need to replicate these changes in https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/Toast/Toast.tsx right? Because we are in the middle of the migration to DSRN package 👀

@Kureev

Kureev commented Mar 27, 2026

Copy link
Copy Markdown
Contributor Author

Hey @Kureev

I think we also need to replicate these changes in https://github.com/MetaMask/metamask-design-system/blob/main/packages/design-system-react-native/src/components/Toast/Toast.tsx right? Because we are in the middle of the migration to DSRN package 👀

Heya 👋 !
Yeah, otherwise we will regress to the same issue. Great catch!

…nfirmation

When a transaction confirms very quickly after approval (e.g., on Linea),
both showToast calls arrive before React processes the first state update,
causing the in-progress toast's hasNoTimeout animation to persist even after
the success toast content renders. Track pending setTimeout with a ref so
only the latest showToast call wins.
@Kureev Kureev changed the title fix: resolve persisting mUSD success toast after rapid transaction confirmation fix(MUSD-402): resolve persisting mUSD success toast after rapid transaction confirmation Mar 27, 2026
@shane-t shane-t added this pull request to the merge queue Apr 13, 2026
Merged via the queue into MetaMask:main with commit 6c57486 Apr 13, 2026
73 of 74 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants