Skip to content

Conversation

@DDDDDanica
Copy link
Contributor

@DDDDDanica DDDDDanica commented Dec 8, 2025

Description

This PR adds proper environment detection to the webpack build system and fixes fragile build target detection in the browserify build.

Problem

Webpack: The webpack build was setting METAMASK_ENVIRONMENT based solely on --env, making it easy to accidentally pollute the production Sentry project with events from local or CI test builds.

Browserify: The getIgnoredFiles() function used fragile substring matching (target.includes('dev')) to determine build type. This worked by accident because task names like scripts:core:test:standardEntryPoints contain the build target as a substring, but would fail for differently named tasks.

Solution

Final Result

Browserify Builds

Command Build Target Environment Notes
yarn start dev development Local dev build
yarn build:test test testing E2E test build
yarn test:e2e:single testDev development Live test build
yarn dist dist other Local dist (no GitHub env vars)
yarn build:prod prod production Production build

Webpack Builds

Command Environment Notes
yarn webpack --env development development Dev build
yarn webpack --env production other Local prod-like build (safe!)
yarn webpack --env production --targetEnvironment production production Explicit production
yarn webpack --test testing Test build

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/5955
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/6014

Manual testing steps

Test script for webpack builds:

echo "=== Webpack Dry Run Tests ===" && \
echo "" && \
echo "Local build:" && yarn webpack --env production --dry-run 2>&1 | grep "Target Environment" && \
echo "Main branch:" && GITHUB_REF_NAME=main yarn webpack --env production --dry-run 2>&1 | grep "Target Environment" && \
echo "Release branch:" && GITHUB_REF_NAME=release/12.0.0 yarn webpack --env production --dry-run 2>&1 | grep "Target Environment" && \
echo "PR:" && GITHUB_EVENT_NAME=pull_request yarn webpack --env production --dry-run 2>&1 | grep "Target Environment" && \
echo "Explicit production:" && yarn webpack --env production --targetEnvironment production --dry-run 2>&1 | grep "Target Environment" && \
echo "Development:" && yarn webpack --env development --dry-run 2>&1 | grep "Target Environment" && \
echo "Test build:" && yarn webpack --test --dry-run 2>&1 | grep "Target Environment" && \
echo "" && \
echo "=== All Tests Completed! ==="

Results:

Screenshot 2026-01-07 at 17 53 56

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

Improves build correctness and safety by formalizing environment and build-target detection.

  • Add getBuildTargetFromTask in development/build/utils.js and use it in development/build/index.js to reliably detect dev/test builds (replacing includes checks); export and test it (utils.test.ts).
  • Implement resolveEnvironment in development/webpack/utils/config.ts to derive MetaMask environment (testing, development, staging, release-candidate, pull-request, other) with explicit override via --targetEnvironment; wire into getVariables and dry-run output.
  • Extend CLI: new --targetEnvironment option and enhanced getDryRunMessage signature/output; update webpack.config.ts to use resolveEnvironment for dry runs.
  • Documentation: add CLI argument docs to development/webpack/README.md.
  • Tests updated/added for CLI and environment behavior.

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

@DDDDDanica DDDDDanica self-assigned this Dec 8, 2025
@DDDDDanica DDDDDanica added the team-extension-platform Extension Platform team label Dec 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

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
Copy link
Collaborator

Builds ready [bb5535f]
UI Startup Metrics (1223 ± 75 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1223102413767512781339
load101885712036710661129
domContentLoaded101185211976710571122
domInteractive21153862236
firstPaint54981120841010201097
backgroundConnect21219525811217237
firstReactRender442996124867
getState3716121184276
initialActions103113
loadScripts80765299964853901
setupStore1174041220
numNetworkReqs86337630
BrowserifyPower User HomeuiStartup18831587271015019582141
load1082893157310911381275
domContentLoaded1069886156210911231256
domInteractive27176292848
firstPaint527102129140210221183
backgroundConnect263202693108243566
firstReactRender44368164652
getState19514635438214268
initialActions105112
loadScripts85467913091079131047
setupStore15114861529
numNetworkReqs69601351467113
WebpackStandard HomeuiStartup823704117660851924
load63356479655670757
domContentLoaded62956079155667752
domInteractive21154262238
firstPaint19390689123186601
backgroundConnect1163471327
firstReactRender59333574662144
getState251463113149
initialActions104112
loadScripts62655878955664750
setupStore1174051317
numNetworkReqs86336629
WebpackPower User HomeuiStartup14681153210216415831726
load73757394195825895
domContentLoaded72956792894816886
domInteractive26166392749
firstPaint263117850190244771
backgroundConnect4367198445119
firstReactRender46405944857
getState20314067965234294
initialActions103112
loadScripts72656592693812884
setupStore1593971433
numNetworkReqs68581101267102
FirefoxBrowserifyStandard HomeuiStartup12591096161111113251474
load103990714258010831165
domContentLoaded103990714248010821164
domInteractive58322343482130
firstPaint------
backgroundConnect4022326353690
firstReactRender35308373652
getState1175371022
initialActions102012
loadScripts101488913967110541113
setupStore1057471023
numNetworkReqs86265725
BrowserifyPower User HomeuiStartup25721610350657030183344
load1540977256853721382311
domContentLoaded1540977256753721382311
domInteractive9832109719471201
firstPaint------
backgroundConnect2151712333081881099
firstReactRender5734182186186
getState1487929647184239
initialActions203123
loadScripts1437959237449519982261
setupStore3343425831207
numNetworkReqs71571171471109
WebpackStandard HomeuiStartup15201327185810215721707
load1243111614546912891363
domContentLoaded1243111614546912891363
domInteractive71312764486149
firstPaint------
backgroundConnect3918140194583
firstReactRender453691104959
getState147199201423
initialActions103122
loadScripts1220110114216712651336
setupStore155219261228
numNetworkReqs86265724
WebpackPower User HomeuiStartup28831808647869532713585
load19341153570266123572568
domContentLoaded19341153570266123572567
domInteractive2613039365171051113
firstPaint------
backgroundConnect1872712852661941010
firstReactRender5638125146088
getState1407832454175256
initialActions217123
loadScripts18351129567763622992472
setupStore654113016937297
numNetworkReqs70501251568116
📊 Page Load Benchmark Results

Current Commit: bb5535f | Date: 12/8/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±40ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 718ms (±38ms) 🟢 | historical mean value: 718ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±12ms) 🟢 | historical mean value: 76ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 40ms 1.01s 1.32s 1.05s 1.32s
domContentLoaded 718ms 38ms 700ms 990ms 737ms 990ms
firstPaint 76ms 12ms 60ms 176ms 88ms 176ms
firstContentfulPaint 76ms 12ms 60ms 176ms 88ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 192 Bytes (0%)

@metamaskbot
Copy link
Collaborator

Builds ready [3d520ee]
UI Startup Metrics (1220 ± 90 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1220103915289012771370
load99983212747610371119
domContentLoaded99382712687510311112
domInteractive20144172039
firstPaint62474130540810211105
backgroundConnect20418425712209230
firstReactRender452998134872
getState38161302344106
initialActions106113
loadScripts796645107772833890
setupStore1363161626
numNetworkReqs86307629
BrowserifyPower User HomeuiStartup18701582232714219602138
load1066905134010311541247
domContentLoaded1052900133110311391233
domInteractive25175582844
firstPaint63499135441810431219
backgroundConnect271204615112246552
firstReactRender42355854454
getState19714667959215270
initialActions102112
loadScripts83969511241039311014
setupStore1595171534
numNetworkReqs69591161467112
WebpackStandard HomeuiStartup80269195150834895
load61354375348650693
domContentLoaded60853874948645690
domInteractive21155072140
firstPaint24397709167209667
backgroundConnect1163571229
firstReactRender58331783761146
getState241254103241
initialActions106113
loadScripts60553674748642688
setupStore1042441218
numNetworkReqs86306629
WebpackPower User HomeuiStartup14701168176314115821705
load73258890484801884
domContentLoaded72458289583792874
domInteractive25166282748
firstPaint27390849209247775
backgroundConnect4375379419172
firstReactRender47396454857
getState20814463963241297
initialActions102111
loadScripts72158089382790872
setupStore16878101439
numNetworkReqs6755111106798
FirefoxBrowserifyStandard HomeuiStartup12421072171313013161458
load103092014209210771231
domContentLoaded103092014199210771231
domInteractive56311663176135
firstPaint------
backgroundConnect3820195283691
firstReactRender34295653549
getState107234921
initialActions1024212
loadScripts100690613918410421156
setupStore1062541023
numNetworkReqs86275725
BrowserifyPower User HomeuiStartup26441656405258631413346
load1606964260254821712356
domContentLoaded1605960260254921712356
domInteractive10830110421176950
firstPaint------
backgroundConnect1832013822532021042
firstReactRender5533175175885
getState146761197114159224
initialActions3154724
loadScripts1521946236150620202263
setupStore3743966330233
numNetworkReqs70401241471113
WebpackStandard HomeuiStartup14581283192711015061648
load1181107414226512321291
domContentLoaded1180107414226512321291
domInteractive49281312761119
firstPaint------
backgroundConnect43191582544111
firstReactRender41339194354
getState137142141219
initialActions103012
loadScripts1158105913196012031269
setupStore126116141120
numNetworkReqs86265825
WebpackPower User HomeuiStartup27711771367858732333561
load19031147280452523572560
domContentLoaded19021147280352523572560
domInteractive153311172284861037
firstPaint------
backgroundConnect145221265203174410
firstReactRender57401221659100
getState1428429851177243
initialActions3045827
loadScripts18061129269550623052454
setupStore3253686125246
numNetworkReqs71571421668111
📊 Page Load Benchmark Results

Current Commit: 3d520ee | Date: 12/8/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±40ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 727ms (±37ms) 🟢 | historical mean value: 718ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±13ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 40ms 1.02s 1.32s 1.06s 1.32s
domContentLoaded 727ms 37ms 709ms 983ms 740ms 983ms
firstPaint 78ms 13ms 60ms 192ms 88ms 192ms
firstContentfulPaint 78ms 13ms 60ms 192ms 88ms 192ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 192 Bytes (0%)

@DDDDDanica DDDDDanica marked this pull request as draft December 8, 2025 21:04
@metamaskbot
Copy link
Collaborator

Builds ready [ec732ff]
UI Startup Metrics (1313 ± 117 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup13131032168911713671509
load1070870137210211231259
domContentLoaded1063860136410111131250
domInteractive2715105212391
firstPaint49898138639710291159
backgroundConnect22420127114232253
firstReactRender5333104166585
getState4117108184974
initialActions106113
loadScripts8466511151988941024
setupStore1383761529
numNetworkReqs1367719671
BrowserifyPower User HomeuiStartup19251548240816920272223
load1103899148712912071321
domContentLoaded1094892147912911981314
domInteractive31171482626106
firstPaint5379914924079941215
backgroundConnect24419861584230551
firstReactRender47386244953
getState218147728126211694
initialActions102112
loadScripts88269612671279841099
setupStore1584461533
numNetworkReqs70551381867128
WebpackStandard HomeuiStartup784650100283838950
load63054888676685775
domContentLoaded62454387975680770
domInteractive251495192086
firstPaint30374833220559740
backgroundConnect1267291327
firstReactRender52301532855124
getState2914119163453
initialActions104113
loadScripts62154087674678767
setupStore1163051320
numNetworkReqs1468921674
WebpackPower User HomeuiStartup15081156221821416771854
load770612997104875930
domContentLoaded763604990103869917
domInteractive34171392929121
firstPaint320107907233359878
backgroundConnect46965710228161
firstReactRender52437355563
getState21612369094242358
initialActions102012
loadScripts759602981102861914
setupStore1665581537
numNetworkReqs70551342069128
FirefoxBrowserifyStandard HomeuiStartup12991092186116113711632
load105391312938811081229
domContentLoaded105290812938811051229
domInteractive63331433086123
firstPaint------
backgroundConnect45211873158113
firstReactRender38307174053
getState157174221228
initialActions103122
loadScripts102489712497710771173
setupStore13555111045
numNetworkReqs1669023981
BrowserifyPower User HomeuiStartup25721596373553229743390
load1574960267250120492345
domContentLoaded1574960267150120492344
domInteractive1323199122088921
firstPaint------
backgroundConnect191221130224200940
firstReactRender5434172175783
getState1356993590146225
initialActions2045423
loadScripts1481946250045719082209
setupStore414100610639156
numNetworkReqs73541271974116
WebpackStandard HomeuiStartup15401273225417616141914
load12801077171311913431497
domContentLoaded12791077171311913431496
domInteractive70272233887142
firstPaint------
backgroundConnect49191432955126
firstReactRender41328894357
getState167178251239
initialActions103112
loadScripts12521064168711113161466
setupStore164169211348
numNetworkReqs1569021873
WebpackPower User HomeuiStartup27131790355147030703386
load19001174278147523202526
domContentLoaded18991174278147623202526
domInteractive248271149356303984
firstPaint------
backgroundConnect144231611190184315
firstReactRender5735135176199
getState1337792590149225
initialActions2010123
loadScripts18451156275845822482492
setupStore234275342574
numNetworkReqs74571372186125
📊 Page Load Benchmark Results

Current Commit: ec732ff | Date: 12/10/2025

📄 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: 734ms (±38ms) 🟢 | historical mean value: 721ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 79ms (±14ms) 🟢 | historical mean value: 79ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 42ms 1.02s 1.38s 1.09s 1.38s
domContentLoaded 734ms 38ms 705ms 1.04s 760ms 1.04s
firstPaint 79ms 14ms 60ms 208ms 88ms 208ms
firstContentfulPaint 79ms 14ms 60ms 208ms 88ms 208ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 192 Bytes (0%)

* @param {string} taskName - The task name or build target.
* @returns {BUILD_TARGETS | string} The extracted build target.
*/
function getBuildTargetFromTask(taskName) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Child processes receive task names (e.g., scripts:core:test:standardEntryPoints) instead of build targets (test). This function extracts the correct build target from task names so getEnvironment() works correctly in child processes.

* @param args - The parsed CLI arguments
* @returns The resolved environment string
*/
export function resolveEnvironment(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously, webpack just used args.test ? 'testing' : env, which meant local --env production builds would report as production to Sentry. Now:

  • production is NEVER auto-detected, it must be explicitly set
  • Git context is checked for proper environment detection

if (args.dryRun) {
console.error(getDryRunMessage(args, features));
const resolvedEnv = resolveEnvironment(args);
console.error(getDryRunMessage(args, features, resolvedEnv));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Show the actual resolved environment in dry-run output.

@metamaskbot
Copy link
Collaborator

Builds ready [b1516e9]
UI Startup Metrics (1277 ± 106 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12771050158410613421472
load104587413438610991188
domContentLoaded103986913358510931182
domInteractive28151322422100
firstPaint58881125441910501174
backgroundConnect21720224610223239
firstReactRender443186125075
getState3916183244290
initialActions108112
loadScripts828666112984881975
setupStore1062331116
numNetworkReqs1368320675
BrowserifyPower User HomeuiStartup19281590263118120072289
load1091873143612811921306
domContentLoaded1081869143112711811298
domInteractive31171432628107
firstPaint58094138442910281262
backgroundConnect257197660105238609
firstReactRender48367155261
getState211144751110206307
initialActions104112
loadScripts86767712221249691080
setupStore1564161432
numNetworkReqs71572032468118
WebpackStandard HomeuiStartup8096761204958481014
load65556297878704796
domContentLoaded65055897177699790
domInteractive2515126202283
firstPaint22582803162212730
backgroundConnect1063651020
firstReactRender52321873151129
getState3114327323652
initialActions103112
loadScripts64755396776696787
setupStore1052841216
numNetworkReqs1468520676
WebpackPower User HomeuiStartup13961061199019415061767
load7356031160109835922
domContentLoaded7285971145108828909
domInteractive32161442828110
firstPaint308951173243336876
backgroundConnect101868818198617
firstReactRender49417355156
getState18714578367188258
initialActions102011
loadScripts7255951134107820907
setupStore16655101538
numNetworkReqs70571482266133
FirefoxBrowserifyStandard HomeuiStartup14281127239019215281810
load1140962217013812011310
domContentLoaded1139962217013812011310
domInteractive86331058105103147
firstPaint------
backgroundConnect60222224474176
firstReactRender41326674155
getState13679101129
initialActions102122
loadScripts1106944215013411641260
setupStore175127211375
numNetworkReqs1568321879
BrowserifyPower User HomeuiStartup25801637363153130233315
load1553966258851020352420
domContentLoaded1552966258751020352420
domInteractive15531125826293964
firstPaint------
backgroundConnect1802311172411921047
firstReactRender5736188205895
getState1216423038147212
initialActions2155524
loadScripts1461944245146819262236
setupStore3943836640190
numNetworkReqs74511302271123
WebpackStandard HomeuiStartup16351337246919217082040
load13321117160510313871528
domContentLoaded13321117159810313851528
domInteractive772930043107139
firstPaint------
backgroundConnect62232274167139
firstReactRender5134662634688
getState207196281679
initialActions107122
loadScripts1300109815629313501479
setupStore18697171559
numNetworkReqs1569222876
WebpackPower User HomeuiStartup27721815399652731703598
load18561153277348322822590
domContentLoaded18561153277348322822590
domInteractive184301079299135997
firstPaint------
backgroundConnect205281025223220937
firstReactRender61401612064108
getState1407829151182235
initialActions3137524
loadScripts17561135259443721732460
setupStore5853908954282
numNetworkReqs70461242366122
📊 Page Load Benchmark Results

Current Commit: b1516e9 | Date: 12/10/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

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

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 37ms 1.01s 1.31s 1.07s 1.31s
domContentLoaded 720ms 34ms 697ms 975ms 741ms 975ms
firstPaint 76ms 13ms 56ms 192ms 84ms 192ms
firstContentfulPaint 76ms 13ms 56ms 192ms 84ms 192ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: -106 Bytes (0%)
  • ui: 54 Bytes (0%)
  • common: 192 Bytes (0%)

@DDDDDanica DDDDDanica marked this pull request as ready for review December 10, 2025 16:24
@metamaskbot
Copy link
Collaborator

Builds ready [6d9fdfb]
UI Startup Metrics (1286 ± 97 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1286108315409713501445
load105188513087811071184
domContentLoaded104588013027810971179
domInteractive2715104192377
firstPaint58882131942210471157
backgroundConnect22020225611224244
firstReactRender4532103134875
getState4018154214776
initialActions103112
loadScripts832680105975881965
setupStore1254061326
numNetworkReqs1367920671
BrowserifyPower User HomeuiStartup18621493250918119472242
load1029838166313411181242
domContentLoaded1017830165213211101234
domInteractive2815141212681
firstPaint62687165642110511187
backgroundConnect23117968691223507
firstReactRender49388885263
getState19714972776198259
initialActions103112
loadScripts82165314191269121020
setupStore1596291434
numNetworkReqs73562163165144
WebpackStandard HomeuiStartup8917201113909541061
load71861393986789871
domContentLoaded71160793485781863
domInteractive2917110212595
firstPaint27886866203252799
backgroundConnect12691111332
firstReactRender60362363567140
getState311583144061
initialActions102011
loadScripts70860593284778857
setupStore1374061329
numNetworkReqs1367619673
WebpackPower User HomeuiStartup15131177212320216821874
load7766341003110900964
domContentLoaded768626999109891957
domInteractive35191813029117
firstPaint31497932236336852
backgroundConnect56858611536387
firstReactRender53447665567
getState21714784994221322
initialActions102012
loadScripts765623989108888953
setupStore1685281537
numNetworkReqs70551392166130
FirefoxBrowserifyStandard HomeuiStartup13471068224119614141785
load1086904199112811241259
domContentLoaded1085904199112811231258
domInteractive74309018987127
firstPaint------
backgroundConnect59233105066182
firstReactRender37305963850
getState177215271191
initialActions103012
loadScripts1052886192711810931205
setupStore155161211146
numNetworkReqs1568721976
BrowserifyPower User HomeuiStartup25381586340552529433271
load1577961247547719962335
domContentLoaded1577960247547719962334
domInteractive10132101115083382
firstPaint------
backgroundConnect2461612853042201056
firstReactRender5536191215778
getState1306423140162203
initialActions41357232
loadScripts1465947236242818582192
setupStore3542615140151
numNetworkReqs74551352180123
WebpackStandard HomeuiStartup16011254221816116761938
load13181132170810213781538
domContentLoaded13181131170710313781538
domInteractive832821940112158
firstPaint------
backgroundConnect61241723973151
firstReactRender42326164456
getState177121181542
initialActions102122
loadScripts1286109816839913401501
setupStore196178271356
numNetworkReqs1568521875
WebpackPower User HomeuiStartup27751736409756632133689
load18951126319653523502619
domContentLoaded18941126319653523502619
domInteractive260311882382180989
firstPaint------
backgroundConnect16729983201202936
firstReactRender59381321665101
getState1448135657180263
initialActions3150627
loadScripts18271108317651522882540
setupStore49595711052179
numNetworkReqs70471252366120
📊 Page Load Benchmark Results

Current Commit: 6d9fdfb | Date: 12/10/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.03s (±43ms) 🟡 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 719ms (±41ms) 🟢 | historical mean value: 720ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±21ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.03s 43ms 1.01s 1.32s 1.06s 1.32s
domContentLoaded 719ms 41ms 699ms 990ms 735ms 990ms
firstPaint 78ms 21ms 60ms 256ms 84ms 256ms
firstContentfulPaint 78ms 21ms 60ms 256ms 84ms 256ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 3.11 KiB (0.06%)
  • ui: 7.28 KiB (0.09%)
  • common: 262 Bytes (0%)

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 6, 2026

Builds ready [b0f9784]
UI Startup Metrics (1269 ± 111 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12691018163811113481450
load1066865130110011261247
domContentLoaded1060859129110011171239
domInteractive2515105192180
firstPaint162651147175188291
backgroundConnect21019424510214237
firstReactRender1594761725
getState371668114557
initialActions106113
loadScripts85765810681009151037
setupStore1262741318
numNetworkReqs171175171168
BrowserifyPower User HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
numNetworkReqs------
WebpackStandard HomeuiStartup8056581143948491014
load65456899084688838
domContentLoaded64956398483683831
domInteractive2614135212083
firstPaint1006042559104214
backgroundConnect2551453128100
firstReactRender16114161728
getState3115103144054
initialActions104112
loadScripts64656197482681828
setupStore1354481533
numNetworkReqs181176171168
WebpackPower User HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
numNetworkReqs------
FirefoxBrowserifyStandard HomeuiStartup13501085181416814491663
load1080931146710811701281
domContentLoaded1080931146710811701275
domInteractive66302384187150
firstPaint------
backgroundConnect57201984969185
firstReactRender1293831317
getState125102101124
initialActions103122
loadScripts104891714489511181197
setupStore133105141144
numNetworkReqs19985191472
BrowserifyPower User HomeuiStartup27591510454264832103506
load17411042278258223492633
domContentLoaded17411042278158223492633
domInteractive123321072174127348
firstPaint------
backgroundConnect3953112344004341166
firstReactRender20124972529
getState136621279152132318
initialActions204123
loadScripts14561015259844114582374
setupStore11051215261741097
numNetworkReqs69221763280155
WebpackStandard HomeuiStartup15151284209617415971878
load12881108157811313491513
domContentLoaded12871108157711313491512
domInteractive762823143107141
firstPaint------
backgroundConnect52192193852127
firstReactRender14105041518
getState165197211445
initialActions102012
loadScripts12561048155310813181471
setupStore1246991235
numNetworkReqs19988201478
WebpackPower User HomeuiStartup27171668427454731593390
load19991133319654825112690
domContentLoaded19991133319654825112690
domInteractive10030131316983311
firstPaint------
backgroundConnect3442712163714081153
firstReactRender19128282228
getState112611053101130179
initialActions203122
loadScripts17261118273644421752429
setupStore634110118940195
numNetworkReqs69211893774172
📊 Page Load Benchmark Results

Current Commit: b0f9784 | Date: 1/6/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±38ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 730ms (±35ms) 🟢 | historical mean value: 728ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 78ms (±11ms) 🟢 | historical mean value: 77ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 38ms 1.02s 1.32s 1.08s 1.32s
domContentLoaded 730ms 35ms 711ms 986ms 763ms 986ms
firstPaint 78ms 11ms 60ms 176ms 84ms 176ms
firstContentfulPaint 78ms 11ms 60ms 176ms 84ms 176ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 192 Bytes (0%)

HowardBraham
HowardBraham previously approved these changes Jan 6, 2026
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 7, 2026

Builds ready [86ad1cc]
UI Startup Metrics (1266 ± 125 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup12661014169912513201495
load1059857142911811051279
domContentLoaded1053854142211711001270
domInteractive251587172178
firstPaint14263986103186249
backgroundConnect21119425610215233
firstReactRender1483251523
getState3615100144261
initialActions107112
loadScripts84965812091168981070
setupStore1273551323
numNetworkReqs171177171166
BrowserifyPower User HomeuiStartup17631415240517618582097
load1073896133210611431293
domContentLoaded1061892132510511311287
domInteractive33171572728105
firstPaint169671190128213311
backgroundConnect25720167483257541
firstReactRender15104131519
getState17912068160198254
initialActions102011
loadScripts84269611151049021067
setupStore1563971536
numNetworkReqs64441211662114
WebpackStandard HomeuiStartup800663106184851989
load63457683261654798
domContentLoaded62956982761648792
domInteractive251591182182
firstPaint1045933750130201
backgroundConnect255126263794
firstReactRender15103041725
getState3314164193860
initialActions102111
loadScripts62656782459645783
setupStore1273971433
numNetworkReqs181178181272
WebpackPower User HomeuiStartup1244975176117713131612
load7766321110104867927
domContentLoaded7696261104103855922
domInteractive33181452828116
firstPaint1486943072196271
backgroundConnect62757014616538
firstReactRender17132221821
getState14312622214149168
initialActions101011
loadScripts7656231094102851919
setupStore15104481440
numNetworkReqs66522092361120
FirefoxBrowserifyStandard HomeuiStartup13721082216020714971780
load1105905182816311851386
domContentLoaded1104905182816311841386
domInteractive61301433385135
firstPaint------
backgroundConnect58202964977156
firstReactRender1293331217
getState13592131228
initialActions102122
loadScripts1068890180114811351339
setupStore134108131144
numNetworkReqs20983191476
BrowserifyPower User HomeuiStartup25161478387855628913248
load1757987265652521872515
domContentLoaded1757987265652521852515
domInteractive923391511185309
firstPaint------
backgroundConnect3892012014079251104
firstReactRender20115372427
getState107541110105111168
initialActions203123
loadScripts1441952246045419602257
setupStore2341593118101
numNetworkReqs75541693280156
WebpackStandard HomeuiStartup16691335245619518212019
load13911142203413914861636
domContentLoaded13911142203313914861635
domInteractive922923246130162
firstPaint------
backgroundConnect64202094781154
firstReactRender1611135121624
getState2262503816102
initialActions103122
loadScripts13491125192112214061534
setupStore2151452714107
numNetworkReqs19981191373
WebpackPower User HomeuiStartup26521634369653530593308
load19881186291153424442640
domContentLoaded19871185291153424442639
domInteractive783097910373206
firstPaint------
backgroundConnect2922511683053491074
firstReactRender211278102445
getState1026319732115165
initialActions218123
loadScripts17861158275147622682481
setupStore215237312067
numNetworkReqs73521753185148
📊 Page Load Benchmark Results

Current Commit: 86ad1cc | Date: 1/7/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.05s (±39ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 729ms (±35ms) 🟢 | historical mean value: 726ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±11ms) 🟢 | historical mean value: 77ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.05s 39ms 1.01s 1.32s 1.09s 1.32s
domContentLoaded 729ms 35ms 704ms 981ms 765ms 981ms
firstPaint 77ms 11ms 60ms 172ms 84ms 172ms
firstContentfulPaint 77ms 11ms 60ms 172ms 84ms 172ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 0 Bytes (0%)
  • common: 192 Bytes (0%)

@Gudahtt
Copy link
Member

Gudahtt commented Jan 7, 2026

The webpack changes look good, but the browserify changes are still a bit confusing to me. The bulk of the changes are a new function getBuildTargetFromTask, but this function is only being used in once place right now (in createManifestTasks). Moreover, in that one place, the problem highlighted does not apply.

The description you gave of the problem is here:

The getEnvironment() function was returning incorrect environment values for child processes during builds, causing Sentry events to be miscategorized.

But the manifest task is not run in a child process, it's only run in the root process. So effectively it's always correct. The browserify-based build script only uses child processes for the script tasks, the slowest ones.

Technically the manifest task is created in each child processes, so if you had added logging to createManifestTasks it would have looked broken. But those created manifest tasks are never run in a child process.

The changes you've made here still make the code easier to follow I think (at least now the manifest tasks in child processes will be correct, even though they're never run). But I just wanted to make sure I wasn't missing something here that would have some impact on the final build.

@DDDDDanica
Copy link
Contributor Author

DDDDDanica commented Jan 7, 2026

@Gudahtt Thanks for pointing it out. And it is actually correct, after tracing through the code more carefully, I can confirm that:

  1. createManifestTasks receives entryTask which is already a valid build target in the root process
  2. In child processes, manifest tasks are created but never run
  3. Script tasks use explicit buildTarget values passed from createTasksForScriptBundles, not entryTask

I've removed those changes in this commit: 60fb0ed

However, while investigating I found a real issue in getIgnoredFiles() - it was using fragile substring matching (target.includes('dev')) that happens to work because task names contain the build target as a substring. I've replaced that with proper build target extraction using the same getBuildTargetFromTask() helper.

The PR now focuses on:

  1. Webpack: Adding --targetEnvironment CLI option with proper environment auto-detection
  2. Browserify: Fixing the fragile getIgnoredFiles() logic
  3. Tests: For both getBuildTargetFromTask() and getEnvironment()

Updated the description as well.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Jan 7, 2026
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 7, 2026

Builds ready [60fb0ed]
UI Startup Metrics (1273 ± 96 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup1273103215969613291418
load106487312998911281180
domContentLoaded105886712808911211164
domInteractive2716105192281
firstPaint168651136152195313
backgroundConnect21619627613221248
firstReactRender14103341623
getState361888124160
initialActions105112
loadScripts848661106989912963
setupStore1263141224
numNetworkReqs171176171167
BrowserifyPower User HomeuiStartup------
load------
domContentLoaded------
domInteractive------
firstPaint------
backgroundConnect------
firstReactRender------
getState------
initialActions------
loadScripts------
setupStore------
numNetworkReqs------
WebpackStandard HomeuiStartup78964499675829947
load63656781166671792
domContentLoaded63156480566667786
domInteractive2515101202083
firstPaint1055836160118245
backgroundConnect285109274489
firstReactRender15103441625
getState311564134057
initialActions104111
loadScripts62856179765663778
setupStore1165061120
numNetworkReqs181181181168
WebpackPower User HomeuiStartup1172950178315612571510
load718581110186782864
domContentLoaded711576107584774853
domInteractive30171542725112
firstPaint1146236662136247
backgroundConnect61755911452471
firstReactRender16133631621
getState14211922118148190
initialActions105111
loadScripts708574106683764850
setupStore1493861435
numNetworkReqs64521291862121
FirefoxBrowserifyStandard HomeuiStartup13751087253223214631796
load1105921221118511621338
domContentLoaded1104921221118511621338
domInteractive70278929186147
firstPaint------
backgroundConnect58182135278180
firstReactRender1294141216
getState1164271125
initialActions102012
loadScripts1071906212416711301278
setupStore164259291147
numNetworkReqs19980191574
BrowserifyPower User HomeuiStartup25001504350257529653249
load17291035281754922542536
domContentLoaded17291035281654922532536
domInteractive12832958198100893
firstPaint------
backgroundConnect3302012933723901110
firstReactRender20115872527
getState1086431838130176
initialActions203123
loadScripts14861018264446520342360
setupStore364102510723108
numNetworkReqs73451793293145
WebpackStandard HomeuiStartup15651237219018416881964
load13121116160111213751499
domContentLoaded13111116160011213731499
domInteractive762920337100134
firstPaint------
backgroundConnect63192364777164
firstReactRender15105851522
getState2172403415105
initialActions103122
loadScripts1270110214989713341451
setupStore205216311589
numNetworkReqs19983191475
WebpackPower User HomeuiStartup26281566387152830623234
load19901162284751924412623
domContentLoaded19901162284752024402623
domInteractive903093713577244
firstPaint------
backgroundConnect3312312143653771097
firstReactRender201367102346
getState996622731108160
initialActions206122
loadScripts17311140262844221852420
setupStore31499910319101
numNetworkReqs74521623078145
📊 Page Load Benchmark Results

Current Commit: 60fb0ed | Date: 1/7/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±56ms) 🟡 | historical mean value: 1.03s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 743ms (±53ms) 🟢 | historical mean value: 717ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±12ms) 🟢 | historical mean value: 76ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 56ms 1.03s 1.35s 1.10s 1.35s
domContentLoaded 743ms 53ms 711ms 1.03s 778ms 1.03s
firstPaint 80ms 12ms 60ms 184ms 88ms 184ms
firstContentfulPaint 80ms 12ms 60ms 184ms 88ms 184ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.72 KiB (0.04%)
  • ui: -2.94 KiB (-0.04%)
  • common: 4.7 KiB (0.05%)

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Jan 7, 2026

Builds ready [0ac4bd5]
UI Startup Metrics (1248 ± 98 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyStandard HomeuiStartup124899515109813031430
load104184512929910961206
domContentLoaded103584012809810891201
domInteractive231597162176
firstPaint159641123145183265
backgroundConnect20819325510213226
firstReactRender1492531521
getState3914128174574
initialActions104112
loadScripts8346441080988881000
setupStore1355161423
numNetworkReqs171180151163
BrowserifyPower User HomeuiStartup17911433239219218812140
load1040873136811811421248
domContentLoaded1030864136011711311241
domInteractive2917125222696
firstPaint1486533362200242
backgroundConnect23920160166236433
firstReactRender14113231518
getState18914631328209233
initialActions103112
loadScripts81766311511168981029
setupStore19649112842
numNetworkReqs66532132263117
WebpackStandard HomeuiStartup7976451142878421015
load64356992274684794
domContentLoaded63956591773679788
domInteractive2515115202182
firstPaint1015834153106214
backgroundConnect235115253386
firstReactRender15113441620
getState3315131203964
initialActions106111
loadScripts63556390872676784
setupStore1264561423
numNetworkReqs181178181173
WebpackPower User HomeuiStartup1266970175820013381699
load716599107492740915
domContentLoaded709592106691731907
domInteractive31171702825100
firstPaint1216240573135308
backgroundConnect1046650171109611
firstReactRender16122321720
getState16013822715166183
initialActions101011
loadScripts706589105890729904
setupStore1693981437
numNetworkReqs65511261663114
FirefoxBrowserifyStandard HomeuiStartup13671089183916914611744
load1090919160611611661294
domContentLoaded1090919160511611651294
domInteractive66322203885161
firstPaint------
backgroundConnect54212264852179
firstReactRender13103751323
getState146133191030
initialActions103122
loadScripts1059903150210011141233
setupStore12571121049
numNetworkReqs19978191376
BrowserifyPower User HomeuiStartup25921553338656830843335
load17191005267255622362549
domContentLoaded17181005267255622362549
domInteractive85333426893276
firstPaint------
backgroundConnect3982412084214591164
firstReactRender20126272229
getState1126927329130158
initialActions3037427
loadScripts1409976244644614742348
setupStore525112115540148
numNetworkReqs74531802984141
WebpackStandard HomeuiStartup15371288216819516201954
load12961093184614213641644
domContentLoaded12961093184614213641643
domInteractive71282054396158
firstPaint------
backgroundConnect60162184679176
firstReactRender1595551623
getState168241251530
initialActions102122
loadScripts12591076177812813211545
setupStore184205321463
numNetworkReqs19883191373
WebpackPower User HomeuiStartup27521607440960531483618
load20601153358957224922784
domContentLoaded20591153358957224922783
domInteractive8929194519678220
firstPaint------
backgroundConnect3432314353673751147
firstReactRender2113156152128
getState1093822131117173
initialActions3028327
loadScripts17951129356551122182591
setupStore405121212622179
numNetworkReqs74511723083147
📊 Page Load Benchmark Results

Current Commit: 0ac4bd5 | Date: 1/7/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±39ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 726ms (±37ms) 🟢 | historical mean value: 724ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 77ms (±10ms) 🟢 | historical mean value: 78ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 39ms 1.02s 1.32s 1.06s 1.32s
domContentLoaded 726ms 37ms 702ms 993ms 743ms 993ms
firstPaint 77ms 10ms 60ms 160ms 88ms 160ms
firstContentfulPaint 77ms 10ms 60ms 160ms 88ms 160ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.75 KiB (0.04%)
  • ui: -2.98 KiB (-0.04%)
  • common: 4.71 KiB (0.05%)

@HowardBraham HowardBraham added this pull request to the merge queue Jan 7, 2026
Merged via the queue into main with commit 8c3cd95 Jan 7, 2026
176 checks passed
@HowardBraham HowardBraham deleted the fix/5955-env-logic branch January 7, 2026 23:15
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
@metamaskbot metamaskbot added the release-13.14.0 Issue or pull request that will be included in release 13.14.0 label Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-13.14.0 Issue or pull request that will be included in release 13.14.0 size-M team-extension-platform Extension Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants