Skip to content

Conversation

@DDDDDanica
Copy link
Contributor

@DDDDDanica DDDDDanica commented Dec 8, 2025

Description

The getEnvironment() function in development/build/utils.js was returning incorrect environment values for child processes during builds, causing Sentry events to be miscategorized. The reason behind is, when MM runs a build command like yarn build:test, it spawns child processes for subtasks. Each child process receives the task name (e.g., scripts:core:test:standardEntryPoints) instead of the build target (test).

Before:

yarn build:test
  └── Main process: buildTarget = "test" ✅
        └── Child process: scripts:core:test:standardEntryPoints
              └── manifest.js calls getEnvironment({ buildTarget: "scripts:core:test:standardEntryPoints" })
                    └── isTestBuild("scripts:core:test:standardEntryPoints") → false ❌
                          └── Falls through to PULL_REQUEST or OTHER ❌

After:

yarn build:test
  └── Main process: buildTarget = "test" ✅
        └── Child process: scripts:core:test:standardEntryPoints
              └── manifest.js calls getBuildTargetFromTask("scripts:core:test:standardEntryPoints")
                    └── Returns "test" ✅
                          └── getEnvironment({ buildTarget: "test" })
                                └── isTestBuild("test") → true ✅
                                      └── Returns TESTING ✅

Final result:

Final Result

Command Build Target Environment Notes
yarn start dev development Local dev build
yarn start:flask dev development Flask dev build
yarn start:mmi dev development MMI dev build
yarn build:test test testing E2E test build
yarn build:test:flask test `testing Flask E2E test build
yarn test:e2e:single testDev development Live test build (isDevBuild=true)
yarn dist dist other Local dist (no GitHub env vars)
yarn build:prod prod production Production build

CI/CD Environments (with GitHub env vars)

Command Branch/Event Environment
yarn dist main branch staging
yarn dist release/x.x.x branch release-candidate
yarn dist pull_request event pull-request
yarn dist other branches other

Open in GitHub Codespaces

Changelog

CHANGELOG entry: null

Related issues

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

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

Ensures correct environment resolution by extracting build targets from task names, centralizing task prefixes, and updating usages with accompanying tests.

  • Build system
    • Environment detection: Added getBuildTargetFromTask in development/build/utils.js and used it in development/build/manifest.js to compute environment from actual build targets.
    • Task prefixes: Introduced TASK_PREFIXES in development/build/constants.js and replaced hardcoded task prefix strings in development/build/scripts.js.
    • Exports/Utils: Exported TASK_PREFIXES and getBuildTargetFromTask for reuse across build tasks.
  • Tests
    • Added development/build/utils.test.ts covering getBuildTargetFromTask and getEnvironment behavior across CI/CD scenarios.

Written by Cursor Bugbot for commit 3d520ee. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size-M team-extension-platform Extension Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants