Skip to content

Conversation

@davidmurdoch
Copy link
Contributor

@davidmurdoch davidmurdoch commented Jan 27, 2026

Description

We switched migrator error reporting to use AggregateError instead of rewriting the original error message.

Problem:
Existing migrator tests still expected the old error rewrite behavior, and didn’t cover v2 migration flow or clone failures.

Solution:
Update migrator unit tests to assert AggregateError emission, verify v2 migration behavior and changed controller reporting, and add a regression test for clone failures (issue 39567).

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Partially Addresses: #39567

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

Medium Risk
Moderate risk because it changes the shape/type of errors emitted from the migrator, which may affect any callers/listeners that inspect error messages or instances. Core migration flow remains the same and is covered by expanded unit tests, reducing regression risk.

Overview
Migrator error reporting now wraps failures in AggregateError (instead of mutating the original error message) and emits that wrapped error via the error event.

Tests were updated and expanded to assert the new emitted error shape, verify v2 migration behavior (including changedKeys tracking), and add a regression case for structuredClone/DataCloneError failures.

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

@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.

@metamaskbot metamaskbot added the team-extension-platform Extension Platform team label Jan 27, 2026
@davidmurdoch davidmurdoch changed the title switch to aggregate error and add tests fix(migrator): prevent crash by throwing AggregateError instead of mutating existing error Jan 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a crash in the migrator by switching from mutating error messages directly to using AggregateError to wrap errors with additional context. The original issue (#39567) involved a TypeError when attempting to set the message property of a DOMException, which has a read-only message getter.

Changes:

  • Modified error handling in migrator to use AggregateError instead of mutating error messages
  • Updated existing test to verify AggregateError emission instead of checking for rewritten error messages
  • Added test for v2 migration flow with changed controller tracking
  • Added regression test for clone failures that produce read-only error objects like DOMException

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
app/scripts/lib/migrator/index.js Updated error handling to wrap errors in AggregateError instead of mutating the original error's message property
app/scripts/lib/migrator/index.test.js Updated tests to assert AggregateError behavior, added v2 migration test with controller tracking, and added regression test for structuredClone failures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +118 to +128
migrator.on('error', onError);

const initialState = { meta: { version: 0 }, data: { hello: 'world' } };
const migratedData = await migrator.migrateData(initialState);

expect(onError).toHaveBeenCalledTimes(1);
const [error] = onError.mock.calls[0];
expect(error).toBeInstanceOf(AggregateError);
expect(error.message).toBe('MetaMask Migration Error #1');
expect(error.errors[0].message).toBe('test');
expect(migratedData.state).toBe(initialState);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The shape of the error is different now.

This DOES effect migration error display sentry.

expect(migratedData.state).toBe(initialState);
});

it('runs v2 migrations and reports changed controllers', async () => {
Copy link
Contributor Author

@davidmurdoch davidmurdoch Jan 27, 2026

Choose a reason for hiding this comment

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

specifically testing the v2 migration flow here

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 27, 2026

Builds ready [93e7590]
UI Startup Metrics (1336 ± 120 ms)
PlatformBuildTypePageMetricTest Title (ms)Persona (ms)Mean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--13361095163012013991554
load--1138915143011911871373
domContentLoaded--1131897142011811791363
domInteractive--2716134202381
firstPaint--159641172124198299
backgroundConnect--23321828812237259
firstReactRender--17103041828
initialActions--106114
loadScripts--91468712071199631146
setupStore--1372941519
numNetworkReqs--191378161367
19--------
BrowserifyPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--21081557611379320244289
load--1056921141911411141335
domContentLoaded--1041913136611210661329
domInteractive--3218131193081
firstPaint--180701380145230366
backgroundConnect--44727431914613301708
firstReactRender--23154772540
initialActions--106113
loadScripts--81268111391068261091
setupStore--1674671734
numNetworkReqs--75391773895165
19--------
WebpackStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--8156521130988801008
load--68058697289734901
domContentLoaded--67658196588726893
domInteractive--2415110182280
firstPaint--1006024345123212
backgroundConnect--38181202540109
firstReactRender--1593551625
initialActions--107111
loadScripts--67357996388724891
setupStore--1163051123
numNetworkReqs--201381181375
19--------
WebpackPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--1313901180421315021607
load--7396211189107744983
domContentLoaded--7296131182107725972
domInteractive--34181572732107
firstPaint--1526846777195292
backgroundConnect--186136609104164477
firstReactRender--22163432429
initialActions--101011
loadScripts--7266111174106723961
setupStore--1152031317
numNetworkReqs--783922344103165
19--------
FirefoxBrowserifyStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--14481142219719315371893
load--1167977189815212141452
domContentLoaded--1166977189815212141452
domInteractive--843389792108149
firstPaint--------
backgroundConnect--68233285878190
firstReactRender--14106781337
initialActions--103012
loadScripts--1134963188214111821294
setupStore--144171231042
numNetworkReqs--211182181575
19--------
BrowserifyPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--26771998499861727234404
load--12861055280137112482519
domContentLoaded--12851055280137112482518
domInteractive--130371091133123364
firstPaint--------
backgroundConnect--3151051216276313981
firstReactRender--21157262329
initialActions--203123
loadScripts--12411022262834612122489
setupStore--20381492286307803
numNetworkReqs--66272274379168
19--------
WebpackStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--16881406222617718272023
load--14381213181612915031683
domContentLoaded--14371211181612915031682
domInteractive--893023042122160
firstPaint--------
backgroundConnect--77282085095184
firstReactRender--14104841418
initialActions--102012
loadScripts--13931196170110514641587
setupStore--1642313011101
numNetworkReqs--211181171569
19--------
WebpackPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--316821719419114231425198
load--17131315766274017402787
domContentLoaded--17131315766174017402787
domInteractive--126361298156116342
firstPaint--------
backgroundConnect--345842081326329947
firstReactRender--2416193182431
initialActions--203123
loadScripts--16351237750071216592761
setupStore--19891613267316722
numNetworkReqs--64262044278169
19--------
📊 Page Load Benchmark Results

Current Commit: 93e7590 | Date: 1/27/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±54ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 729ms (±51ms) 🟢 | historical mean value: 723ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±12ms) 🟢 | historical mean value: 80ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 54ms 1.00s 1.34s 1.10s 1.34s
domContentLoaded 729ms 51ms 695ms 1.01s 769ms 1.01s
firstPaint 77ms 12ms 64ms 184ms 84ms 184ms
firstContentfulPaint 77ms 12ms 64ms 184ms 84ms 184ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 56 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 28, 2026

Builds ready [14c66fd]
UI Startup Metrics (1309 ± 128 ms)
PlatformBuildTypePageMetricTest Title (ms)Persona (ms)Mean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--13091070187712813621534
load--1119905153211711681311
domContentLoaded--1112901152411711611302
domInteractive--261590172374
firstPaint--174621316189194277
backgroundConnect--23221728011237256
firstReactRender--17104461930
initialActions--106114
loadScripts--89668912931159501087
setupStore--1363661526
numNetworkReqs--191382161364
19--------
BrowserifyPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--312816398642154643916089
load--1160978159512912571415
domContentLoaded--1141961158812512181390
domInteractive--38182833733114
firstPaint--222801430200256386
backgroundConnect--10522803739102421023128
firstReactRender--25164472841
initialActions--105112
loadScripts--90573813251219761163
setupStore--1565071829
numNetworkReqs--954123438100199
19--------
WebpackStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--84867411421059171034
load--70659897193776908
domContentLoaded--70159496592772904
domInteractive--241597162272
firstPaint--1016028747120191
backgroundConnect--3719145244099
firstReactRender--1593151728
initialActions--106112
loadScripts--69859296391769903
setupStore--1265571223
numNetworkReqs--201382191379
19--------
WebpackPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--1279872242526614591791
load--7306311115108730988
domContentLoaded--7186221103108715978
domInteractive--3719138233695
firstPaint--15667984107193279
backgroundConnect--16513454271154398
firstReactRender--22175352329
initialActions--103111
loadScripts--7166201095106713976
setupStore--1243851519
numNetworkReqs--1004923344107223
19--------
FirefoxBrowserifyStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--15271232207317316231849
load--12381052157511813091478
domContentLoaded--12371045157411813091477
domInteractive--893823846111180
firstPaint--------
backgroundConnect--822836060113194
firstReactRender--15104561531
initialActions--103122
loadScripts--1191103714799812421382
setupStore--156185221248
numNetworkReqs--221193211781
19--------
BrowserifyPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--26941771766381728323784
load--13151021521746113041987
domContentLoaded--13151021521746113041986
domInteractive--1353963287154343
firstPaint--------
backgroundConnect--40610614263235691227
firstReactRender--20143642227
initialActions--203123
loadScripts--12601007516045012531945
setupStore--13713858170150550
numNetworkReqs--83312364587205
19--------
WebpackStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--16141285200016617351958
load--13911209172912914601647
domContentLoaded--13901208172912914601647
domInteractive--832524347113150
firstPaint--------
backgroundConnect--68242344479158
firstReactRender--13102721418
initialActions--102112
loadScripts--13531194166410814311562
setupStore--145187231135
numNetworkReqs--201181171569
19--------
WebpackPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--29532102566359532764245
load--16011262380640016572596
domContentLoaded--16011262380640016572595
domInteractive--13233691104140322
firstPaint--------
backgroundConnect--43911214533296971062
firstReactRender--21153142430
initialActions--203123
loadScripts--15521198359437716152555
setupStore--1499778189203630
numNetworkReqs--76312734880199
19--------
📊 Page Load Benchmark Results

Current Commit: 14c66fd | Date: 1/27/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.02s (±37ms) 🟡 | historical mean value: 1.04s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 714ms (±34ms) 🟢 | historical mean value: 724ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±13ms) 🟢 | historical mean value: 80ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.02s 37ms 968ms 1.27s 1.05s 1.27s
domContentLoaded 714ms 34ms 671ms 950ms 731ms 950ms
firstPaint 76ms 13ms 60ms 192ms 84ms 192ms
firstContentfulPaint 76ms 13ms 60ms 192ms 84ms 192ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 56 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 28, 2026

Builds ready [77d5acd]
UI Startup Metrics (1289 ± 97 ms)
PlatformBuildTypePageMetricTest Title (ms)Persona (ms)Mean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--1289105916109713461448
load--108990214049311521235
domContentLoaded--108289813969311451225
domInteractive--261589182379
firstPaint--168641201182188359
backgroundConnect--23021228013234262
firstReactRender--17105271934
initialActions--107113
loadScripts--8666741164939361006
setupStore--1363661722
numNetworkReqs--221584181576
19--------
BrowserifyPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--20941613505161221093076
load--1075943166614410941432
domContentLoaded--1058932164813810691379
domInteractive--3517154243595
firstPaint--215671437223232386
backgroundConnect--4182822571352332952
firstReactRender--24155682645
initialActions--105112
loadScripts--82771113761298411115
setupStore--1765991840
numNetworkReqs--1295332056154245
19--------
WebpackStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--8446701202938951025
load--701605105775752829
domContentLoaded--696602104274749823
domInteractive--2616121192376
firstPaint--1166347466129232
backgroundConnect--39181292342103
firstReactRender--16103351929
initialActions--104113
loadScripts--693600103573745816
setupStore--1373561425
numNetworkReqs--211581161572
19--------
WebpackPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--1272843197121914581586
load--71461012971177121000
domContentLoaded--7036011290116705986
domInteractive--36182213331106
firstPaint--14864984123153459
backgroundConnect--17213258690158441
firstReactRender--22173832428
initialActions--104111
loadScripts--7005991282115703977
setupStore--1242941418
numNetworkReqs--1366128456160254
19--------
FirefoxBrowserifyStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--15121186223518416011901
load--1225998183214912861456
domContentLoaded--1224998183214912861456
domInteractive--893524056126210
firstPaint--------
backgroundConnect--782827554115176
firstReactRender--14104561418
initialActions--103122
loadScripts--1179983180313712381422
setupStore--174232341154
numNetworkReqs--231283171874
19--------
BrowserifyPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--25741690529061626564317
load--12581035264429712411848
domContentLoaded--12581034264429712411848
domInteractive--134351082148122380
firstPaint--------
backgroundConnect--281761677274233909
firstReactRender--21146162229
initialActions--213123
loadScripts--12151017261826012021752
setupStore--1495771201150669
numNetworkReqs--73382254191177
19--------
WebpackStandard Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--16671330220318817892032
load--14121147192213815031657
domContentLoaded--14121147192213815031657
domInteractive--863015840129143
firstPaint--------
backgroundConnect--802620749122177
firstReactRender--14103231419
initialActions--102022
loadScripts--13651116182111414241543
setupStore--2232133812122
numNetworkReqs--221281171871
19--------
WebpackPower User Home0--------
1--------
2--------
3--------
4--------
5--------
6--------
7--------
8--------
9--------
10--------
11--------
12--------
13--------
14--------
15--------
16--------
17--------
18--------
uiStartup--308821508943100735484587
load--17391191731486517723001
domContentLoaded--17391190731486517713001
domInteractive--164325240526111388
firstPaint--------
backgroundConnect--3471181173269370929
firstReactRender--22155462431
initialActions--207123
loadScripts--16921178729085017112935
setupStore--1607810225151723
numNetworkReqs--72392104181179
19--------
📊 Page Load Benchmark Results

Current Commit: 77d5acd | Date: 1/28/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±37ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 722ms (±35ms) 🟢 | historical mean value: 720ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±11ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 37ms 1.01s 1.31s 1.06s 1.31s
domContentLoaded 722ms 35ms 697ms 980ms 737ms 980ms
firstPaint 77ms 11ms 60ms 176ms 84ms 176ms
firstContentfulPaint 77ms 11ms 60ms 176ms 84ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 56 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 20 Bytes (0%)

@davidmurdoch davidmurdoch marked this pull request as ready for review January 29, 2026 18:14
@davidmurdoch davidmurdoch requested a review from Gudahtt January 29, 2026 18:14
@github-project-automation github-project-automation bot moved this to Needs dev review in PR review queue Jan 29, 2026
@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Jan 30, 2026
@davidmurdoch davidmurdoch added this pull request to the merge queue Jan 30, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 30, 2026
…mutating existing error (#39582)

## **Description**

We switched migrator error reporting to use AggregateError instead of
rewriting the original error message.

Problem:
Existing migrator tests still expected the old error rewrite behavior,
and didn’t cover v2 migration flow or clone failures.

Solution:
Update migrator unit tests to assert AggregateError emission, verify v2
migration behavior and changed controller reporting, and add a
regression test for clone failures (issue 39567).

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/39582?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: null

## **Related issues**

Partially Addresses:
#39567
<!--
## **Manual testing steps**

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

## **Screenshots/Recordings**


### **Before**


### **After**

-->
## **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]
> **Medium Risk**
> Moderate risk because it changes the shape/type of errors emitted from
the migrator, which may affect any callers/listeners that inspect error
messages or instances. Core migration flow remains the same and is
covered by expanded unit tests, reducing regression risk.
> 
> **Overview**
> **Migrator error reporting now wraps failures in `AggregateError`**
(instead of mutating the original error message) and emits that wrapped
error via the `error` event.
> 
> **Tests were updated and expanded** to assert the new emitted error
shape, verify v2 migration behavior (including `changedKeys` tracking),
and add a regression case for `structuredClone`/`DataCloneError`
failures.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
77d5acd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Copilot <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2026
@davidmurdoch davidmurdoch added this pull request to the merge queue Jan 30, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2026
@davidmurdoch davidmurdoch added this pull request to the merge queue Jan 30, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 30, 2026
…mutating existing error (#39582)

## **Description**

We switched migrator error reporting to use AggregateError instead of
rewriting the original error message.

Problem:
Existing migrator tests still expected the old error rewrite behavior,
and didn’t cover v2 migration flow or clone failures.

Solution:
Update migrator unit tests to assert AggregateError emission, verify v2
migration behavior and changed controller reporting, and add a
regression test for clone failures (issue 39567).

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/39582?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: null

## **Related issues**

Partially Addresses:
#39567
<!--
## **Manual testing steps**

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

## **Screenshots/Recordings**


### **Before**


### **After**

-->
## **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]
> **Medium Risk**
> Moderate risk because it changes the shape/type of errors emitted from
the migrator, which may affect any callers/listeners that inspect error
messages or instances. Core migration flow remains the same and is
covered by expanded unit tests, reducing regression risk.
> 
> **Overview**
> **Migrator error reporting now wraps failures in `AggregateError`**
(instead of mutating the original error message) and emits that wrapped
error via the `error` event.
> 
> **Tests were updated and expanded** to assert the new emitted error
shape, verify v2 migration behavior (including `changedKeys` tracking),
and add a regression case for `structuredClone`/`DataCloneError`
failures.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
77d5acd. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: Copilot <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2026
@davidmurdoch davidmurdoch added this pull request to the merge queue Jan 30, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2026
@davidmurdoch davidmurdoch added this pull request to the merge queue Jan 30, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 30, 2026
@davidmurdoch davidmurdoch added this pull request to the merge queue Jan 31, 2026
Merged via the queue into main with commit 3e97e0c Jan 31, 2026
184 checks passed
@davidmurdoch davidmurdoch deleted the fix-migration-error-catch branch January 31, 2026 00:51
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2026
@metamaskbot metamaskbot added the release-13.18.0 Issue or pull request that will be included in release 13.18.0 label Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-13.18.0 Issue or pull request that will be included in release 13.18.0 size-S team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants