Skip to content

fix: wait for bridge tx submission before navigating to activity log#40173

Merged
micaelae merged 3 commits intomainfrom
swaps4060-submitTx-account-error
Feb 18, 2026
Merged

fix: wait for bridge tx submission before navigating to activity log#40173
micaelae merged 3 commits intomainfrom
swaps4060-submitTx-account-error

Conversation

@micaelae
Copy link
Member

@micaelae micaelae commented Feb 17, 2026

Description

This is what currently happens when a user submits a swap/bridge tx

  1. Publish submission metrics
  2. Add transaction to the background state
  3. Route to the Activity log while the transaction is pending
  4. Reset bridge controller state on page unload

Since the async submitTx handler is not awaited, #4 can happen before steps 1-3, which causes the tracking error described in the bug ticket. This scenario is only possible if the user submits the trade right after they receive it and their network connection is slow

Open in GitHub Codespaces

Changelog

CHANGELOG entry: fix: swap tx submission fails if page navigates to Activity log before QuotesReceived event is published

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4060 , #39871

Manual testing steps

  1. Open dev console
  2. Request a swap quote
  3. Submit right when first quote appears
  4. Check if console logs include request cancellation logs (to verify that the edge case was hit). Otherwise repeat prior steps again
  5. Verify that tx got submitted
  6. Verify in network tab that a "Quotes Received" event was published

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Small control-flow change to await an existing async submission before navigation; low risk but could affect perceived UI timing if the background call is slow.

Overview
Ensures bridge/swap submissions fully complete before routing the user to the Activity tab to avoid losing side effects (e.g., metrics/state updates) on page unload.

This makes submitBridgeTx async and updates useSubmitBridgeTransaction to await the thunk creation and dispatch for both non-EVM and EVM flows. It also makes error navigation to Activity consistent by passing state: { stayOnHomePage: true } when redirecting after failures.

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

@metamaskbot metamaskbot added the team-swaps-and-bridge Swaps and Bridge team label Feb 17, 2026
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 17, 2026

✨ Files requiring CODEOWNER review ✨

🔄 @MetaMask/swaps-engineers (2 files, +7 -5)
  • 📁 ui/
    • 📁 ducks/
      • 📁 bridge-status/
        • 📄 actions.ts +2 -2
    • 📁 pages/
      • 📁 bridge/
        • 📁 hooks/
          • 📄 useSubmitBridgeTransaction.ts +5 -3

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 17, 2026

Builds ready [4b04169]
UI Startup Metrics (1394 ± 98 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1394119816309814641552
load1205102114089412611360
domContentLoaded1197101713989212531342
domInteractive2717115192475
firstPaint175701325172211332
backgroundConnect25723344528259287
firstReactRender18104362133
initialActions107113
loadScripts95777711599110191105
setupStore1473051626
numNetworkReqs231591211583
BrowserifyPower User HomeuiStartup19061570243915019422234
load12971166201617312791749
domContentLoaded12771158190216012611705
domInteractive3920167234256
firstPaint219801914190276338
backgroundConnect36533043924377412
firstReactRender25185362934
initialActions104112
loadScripts99486715911559791424
setupStore1894771933
numNetworkReqs1074623241133176
WebpackStandard HomeuiStartup8586961214999471002
load748620106595845897
domContentLoaded742615105694833891
domInteractive2816110202484
firstPaint1236540554160205
backgroundConnect27185283241
firstReactRender14103541721
initialActions103112
loadScripts740613104893825888
setupStore1163041220
numNetworkReqs231594201582
WebpackPower User HomeuiStartup1321914225917613921602
load78167314951407721160
domContentLoaded77066814771397571150
domInteractive42201633239134
firstPaint1597651493164368
backgroundConnect17613836141183281
firstReactRender25195152631
initialActions102111
loadScripts76766614661377551139
setupStore1353651618
numNetworkReqs1174525446144207
FirefoxBrowserifyStandard HomeuiStartup15221329228617815511916
load13161151181013713591652
domContentLoaded13151151181013713591652
domInteractive63332494680139
firstPaint------
backgroundConnect5426245245381
firstReactRender12102631217
initialActions102112
loadScripts12911124169913313311627
setupStore156172251238
numNetworkReqs241292211783
BrowserifyPower User HomeuiStartup28292069464446430203633
load16141306255529216352274
domContentLoaded16131306255529216342274
domInteractive13534718139122466
firstPaint------
backgroundConnect333106944262440932
firstReactRender201575101927
initialActions203122
loadScripts15771281252628515902197
setupStore1248706173116593
numNetworkReqs68361583686142
WebpackStandard HomeuiStartup15891338216413916541839
load13831182164810114601556
domContentLoaded13821177164810114601556
domInteractive782524851112174
firstPaint------
backgroundConnect55271722858124
firstReactRender14112431422
initialActions102012
loadScripts1358116516179714291536
setupStore166218281142
numNetworkReqs241387191880
WebpackPower User HomeuiStartup28112122427545529763699
load16291277312034017292365
domContentLoaded16291277312034017292365
domInteractive13634945169113588
firstPaint------
backgroundConnect3511321299269352907
firstReactRender24166362733
initialActions203122
loadScripts15811260305131217022207
setupStore184101029242263689
numNetworkReqs67362094080140
📊 Page Load Benchmark Results

Current Commit: 4b04169 | Date: 2/17/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±45ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 734ms (±39ms) 🟢 | historical mean value: 730ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±15ms) 🟢 | historical mean value: 83ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 45ms 1.02s 1.35s 1.09s 1.35s
domContentLoaded 734ms 39ms 710ms 1.02s 753ms 1.02s
firstPaint 81ms 15ms 64ms 216ms 92ms 216ms
firstContentfulPaint 81ms 15ms 64ms 216ms 92ms 216ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 54 Bytes (0%)
  • common: 20 Bytes (0%)

@micaelae micaelae marked this pull request as ready for review February 17, 2026 20:17
@micaelae micaelae requested a review from a team as a code owner February 17, 2026 20:17
@micaelae micaelae enabled auto-merge February 17, 2026 20:19
} else {
navigate(`${DEFAULT_ROUTE}?tab=activity`);
navigate(`${DEFAULT_ROUTE}?tab=activity`, {
state: { stayOnHomePage: true },
Copy link
Member Author

Choose a reason for hiding this comment

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

When using the sidepanel extension, this causes the UI to navigate to the activity list if submission fails. Currently the user doesn't get an indication that their tx failed

Copy link

@cursor cursor bot left a comment

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.

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Feb 18, 2026

Builds ready [4e21743]
UI Startup Metrics (1393 ± 107 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13931209183910714371555
load1205101716129812421353
domContentLoaded1197101016049712371347
domInteractive2817117202483
firstPaint1507035968206272
backgroundConnect25223441619255272
firstReactRender1910232221826
initialActions104113
loadScripts9607661363969991109
setupStore1373951520
numNetworkReqs231589201579
BrowserifyPower User HomeuiStartup3471168411087226038459776
load13121139177212313581612
domContentLoaded12941126176211913421551
domInteractive39202663435118
firstPaint1958344987267336
backgroundConnect12693178859160313994378
firstReactRender25185462837
initialActions105112
loadScripts1026870147511710471286
setupStore1674371734
numNetworkReqs955317426105148
WebpackStandard HomeuiStartup949730148312210181134
load82665112451098921003
domContentLoaded8206461233108881994
domInteractive3017108222591
firstPaint1446739272190293
backgroundConnect30217393448
firstReactRender16113341825
initialActions104112
loadScripts8176441224107878992
setupStore1474271429
numNetworkReqs231589201582
WebpackPower User HomeuiStartup1372911321531914471904
load78967912261127911068
domContentLoaded77667112151137771062
domInteractive42211662941117
firstPaint1727646782220347
backgroundConnect2021331531178172347
firstReactRender24183942533
initialActions103111
loadScripts77366911991117751051
setupStore1354261622
numNetworkReqs1175720933146179
FirefoxBrowserifyStandard HomeuiStartup15911329195613016401899
load13801179171110914281627
domContentLoaded13791175171010914281619
domInteractive82332474598161
firstPaint------
backgroundConnect5425130155879
firstReactRender13102631316
initialActions103112
loadScripts13541165168210413971584
setupStore157170201337
numNetworkReqs241295201882
BrowserifyPower User HomeuiStartup29052143759961329833588
load16261312633155215762113
domContentLoaded16251312633155215752108
domInteractive202491770245183671
firstPaint------
backgroundConnect4621171424300663986
firstReactRender20156991930
initialActions105122
loadScripts15861293629155015232048
setupStore15212715184213637
numNetworkReqs964518331117160
WebpackStandard HomeuiStartup16571372318620417001915
load14261193181410214791587
domContentLoaded14251189181410214791587
domInteractive952821344131154
firstPaint------
backgroundConnect7319146714562168
firstReactRender14112931420
initialActions102112
loadScripts1401117917059614491564
setupStore146173181234
numNetworkReqs241390191777
WebpackPower User HomeuiStartup28972083743071930223474
load16801322629766916862230
domContentLoaded16801322629766916822230
domInteractive187531202190200575
firstPaint------
backgroundConnect50812913363127411056
firstReactRender23154662632
initialActions216122
loadScripts16331304625766915802199
setupStore11917712139117450
numNetworkReqs96462343596165
📊 Page Load Benchmark Results

Current Commit: 4e21743 | Date: 2/18/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±42ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 739ms (±40ms) 🟢 | historical mean value: 729ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±10ms) 🟢 | historical mean value: 83ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 42ms 1.02s 1.37s 1.09s 1.37s
domContentLoaded 739ms 40ms 714ms 1.05s 770ms 1.05s
firstPaint 81ms 10ms 64ms 164ms 88ms 164ms
firstContentfulPaint 81ms 10ms 64ms 164ms 88ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 54 Bytes (0%)
  • common: 20 Bytes (0%)

@micaelae micaelae added this pull request to the merge queue Feb 18, 2026
Merged via the queue into main with commit 2dccff3 Feb 18, 2026
177 checks passed
@micaelae micaelae deleted the swaps4060-submitTx-account-error branch February 18, 2026 14:04
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2026
@metamaskbot metamaskbot added the release-13.20.0 Issue or pull request that will be included in release 13.20.0 label Feb 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.20.0 Issue or pull request that will be included in release 13.20.0 size-S team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants