Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Oct 23, 2025

Description

When adding a network the selectedNetworkClientId was not being
updated and many of our components still depend on it. That is why a
refresh was needed after adding a network

Open in GitHub Codespaces

Changelog

CHANGELOG entry: when adding a network the selectedNetworkClientId was
not being updated and many of our components still depend on it

Related issues

Fixes: #36845 &
#36752
Maybe also fixes:
#36806

Manual testing steps

  1. Go to this page...

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

Ensure newly added networks are immediately set active (updating selectedNetworkClientId) and simplify UI flow to rely on this behavior.

  • Controller:
    • Add _addNetworkAndSetActive to add a network and set its networkClientId active.
    • Replace addNetwork API bindings to use _addNetworkAndSetActive in getApi() and EIP-1193 provider setup.
  • UI:
    • Simplify networks-form add flow: remove manual setActiveNetwork and rely on addNetwork to activate; minor type/import cleanup.
  • Changelog:
    • Note fix where adding a network did not update selectedNetworkClientId.

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


Co-authored-by: davidrentc [email protected]
Co-authored-by: Salim TOUBAL [email protected] 6e9ff43

…nce (#37062)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
When adding a network the `selectedNetworkClientId` was not being
updated and many of our components still depend on it. That is why a
refresh was needed after adding a network

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37062?quickstart=1)

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: when adding a network the `selectedNetworkClientId` was
not being updated and many of our components still depend on it

## **Related issues**

Fixes: #36845 &
#36752
Maybe also fixes:
#36806

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adding a network now automatically becomes the active network; UI no
longer manually sets it active.
> 
> - **Background (controller)**:
> - Add `_addNetworkAndSetActive(networkConfiguration)` to add a network
then set it active via its default RPC endpoint `networkClientId`.
> - Replace exposed `addNetwork` API usages to call
`_addNetworkAndSetActive` (both general UI API and multichain provider
API paths).
> - **UI (networks form)**:
> - Remove manual `setActiveNetwork` after `addNetwork`; rely on
background to activate the new network.
> - Clean up related imports/types; still enables the network post-add.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3b5c1cd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: davidrentc <[email protected]>
Co-authored-by: Salim TOUBAL <[email protected]>
@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Oct 23, 2025
@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 95cf931 | Date: 10/23/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.07s (±74ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 754ms (±72ms) 🟢 | historical mean value: 738ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±12ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.07s 74ms 1.03s 1.37s 1.30s 1.37s
domContentLoaded 754ms 72ms 718ms 1.04s 977ms 1.04s
firstPaint 79ms 12ms 60ms 176ms 92ms 176ms
firstContentfulPaint 79ms 12ms 60ms 176ms 92ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [95cf931]
UI Startup Metrics (1231 ± 90 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1231109118909012771334
load105791416738611071148
domContentLoaded105290916648611011142
domInteractive18135891642
firstPaint614113169443610671133
backgroundConnect2502382676254261
firstReactRender2518120112634
getState18585122136
initialActions60629617
loadScripts807672141385857898
setupStore1062541219
WebpackHomeuiStartup821709103953842920
load62057589154629727
domContentLoaded61256888253623720
domInteractive15114871334
firstPaint17754823168173599
backgroundConnect21104262532
firstReactRender26175473133
getState932031114
initialActions309246
loadScripts60956787151621709
setupStore951521113
FirefoxBrowserifyHomeuiStartup14151250170910914801662
load1202107113587612611338
domContentLoaded1202107113587612611337
domInteractive1103528647114230
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3320132163662
firstReactRender25215142536
getState9210012818
initialActions5111512312
loadScripts1179105113397412361315
setupStore135191221148
WebpackHomeuiStartup15921429198010316301847
load1364122317668013941513
domContentLoaded1363122217668013941512
domInteractive1033435950114224
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect382299144367
firstReactRender312281133073
getState105115111116
initialActions521331347
loadScripts1339120217417713731494
setupStore126111141033

@github-actions
Copy link
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.

addedNetwork?.rpcEndpoints?.[addedNetwork.defaultRpcEndpointIndex] ?? {};
await this.networkController.setActiveNetwork(networkClientId);
return addedNetwork;
}
Copy link

Choose a reason for hiding this comment

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

Bug: Network Controller State Corruption

The _addNetworkAndSetActive method can pass undefined to setActiveNetwork. This happens when destructuring networkClientId from addedNetwork?.rpcEndpoints?.[addedNetwork.defaultRpcEndpointIndex] ?? {} if the RPC endpoint is missing or malformed, potentially leading to an invalid network controller state or errors.

Fix in Cursor Fix in Web

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: 3854b91 | Date: 10/23/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±75ms) 🟡 | historical mean value: 1.05s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±71ms) 🟢 | historical mean value: 735ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±13ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 75ms 994ms 1.33s 1.28s 1.33s
domContentLoaded 732ms 71ms 690ms 1.01s 975ms 1.01s
firstPaint 76ms 13ms 60ms 192ms 88ms 192ms
firstContentfulPaint 76ms 13ms 60ms 192ms 88ms 192ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [3854b91]
UI Startup Metrics (1317 ± 85 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1317114116058513721473
load113299413847711801273
domContentLoaded112699113807711741266
domInteractive18144761828
firstPaint646150132145711391273
backgroundConnect26224130710267282
firstReactRender29206273243
getState1665071929
initialActions607510619
loadScripts8707461098739161006
setupStore1163641217
WebpackHomeuiStartup825708108067849959
load62957792167636780
domContentLoaded62157091267626764
domInteractive15115281334
firstPaint19755865191192598
backgroundConnect21105282634
firstReactRender2716153153141
getState841831112
initialActions309248
loadScripts61856890265624762
setupStore951631114
FirefoxBrowserifyHomeuiStartup15231297206215115711940
load1283111315599213551461
domContentLoaded1282111315589213551460
domInteractive1203735154123262
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect3922224254097
firstReactRender27216262737
getState1049612825
initialActions10219533426
loadScripts1256109115338913301409
setupStore156232301133
WebpackHomeuiStartup16341440213512516731880
load1399119917109414651553
domContentLoaded1398119917099414651553
domInteractive1153139380112359
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect402397154473
firstReactRender322283143476
getState1049610917
initialActions517511414
loadScripts1373116916859114381532
setupStore13593151155

@gauthierpetetin gauthierpetetin merged commit f86bb71 into release/13.6.0 Oct 23, 2025
313 of 319 checks passed
@gauthierpetetin gauthierpetetin deleted the runway-cherry-pick-13.6.0-1761241490 branch October 23, 2025 20:32
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2025
@metamaskbot metamaskbot added the release-13.6.0 Issue or pull request that will be included in release 13.6.0 label Oct 23, 2025
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-13.6.0 on PR, as PR was cherry-picked in branch 13.6.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.6.0 Issue or pull request that will be included in release 13.6.0 team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants