Skip to content

refactor: convert app/scripts/lib/stream-utils.js to TypeScript#41475

Merged
DDDDDanica merged 3 commits intomainfrom
copilot/convert-stream-utils-to-typescript
Apr 7, 2026
Merged

refactor: convert app/scripts/lib/stream-utils.js to TypeScript#41475
DDDDDanica merged 3 commits intomainfrom
copilot/convert-stream-utils-to-typescript

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

[skip-e2e]
Converts app/scripts/lib/stream-utils.js to TypeScript as part of the ongoing TS migration effort, and removes its entry from files-to-convert.json.

Changes

  • stream-utils.ts — renamed from .js with the following type additions:
    • StreamLike type capturing the internal stream properties accessed by isStreamWritable across implementations (node:stream, readable-stream v2/v3/v4, @metamask/object-multiplex)
    • setupMultiplex: parameter typed as Duplex, return typed as ObjectMultiplex
    • isStreamWritable: parameter typed as StreamLike, return typed as boolean; pipeline error callback typed as Error | null
    • pipeline import uses // @ts-expect-error (consistent with provider-stream.ts, phishing-stream.ts, cookie-handler-stream.ts)
    • Inner /** */ docblock inside isStreamWritable converted to /* */ to satisfy jsdoc/check-indentation
type StreamLike = {
  writable?: boolean;
  destroyed?: boolean;
  _writableState?: { ended: boolean };
};

export function setupMultiplex(connectionStream: Duplex): ObjectMultiplex { ... }
export function isStreamWritable(stream: StreamLike): boolean { ... }
  • files-to-convert.json — removed "app/scripts/lib/stream-utils.js" entry

Note

Low Risk
Low risk TS migration change that primarily adds typings and adjusts imports/comments; runtime behavior should be unchanged aside from slightly stricter stream type expectations at compile time.

Overview
Converts app/scripts/lib/stream-utils from JS to TS, adding explicit types for setupMultiplex (now Duplex -> ObjectMultiplex) and isStreamWritable (now accepts a StreamLike shape used across multiple stream implementations).

Adjusts the readable-stream import to include Duplex with a @ts-expect-error and tightens the pipeline error callback type, and removes stream-utils.js from the TS migration dashboard list.

Reviewed by Cursor Bugbot for commit 0c2a1f1. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI changed the title [WIP] Convert app/scripts/lib/stream-utils.js to TypeScript feat: convert app/scripts/lib/stream-utils.js to TypeScript Apr 3, 2026
Copilot AI requested a review from DDDDDanica April 3, 2026 09:43
@DDDDDanica DDDDDanica changed the title feat: convert app/scripts/lib/stream-utils.js to TypeScript refactor: convert app/scripts/lib/stream-utils.js to TypeScript Apr 3, 2026
@github-actions github-actions Bot added the size-S label Apr 3, 2026
@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 Bot commented Apr 3, 2026

Builds ready [b438d0c]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 12 warn · 🔴 0 fail)

Baseline (latest main): f34f804 | Date: 9/10/58222 | Pipeline: 23941922795 | Baseline logs

Interaction Benchmarks
Benchmarkchrome-browserify
loadNewAccount🟡 [Show logs]
confirmTx🟡 [Show logs]
bridgeUserActions🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • bridgeUserActions/bridge_load_page: +13%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 2.5s
  • 🟡 confirmTx/FCP: p75 2.5s
  • 🟡 bridgeUserActions/FCP: p75 2.5s
Startup Benchmarks
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/uiStartup: -10%
  • startupStandardHome/load: -12%
  • startupStandardHome/domContentLoaded: -13%
  • startupStandardHome/domInteractive: +17%
  • startupStandardHome/backgroundConnect: +13%
  • startupStandardHome/initialActions: -38%
  • startupStandardHome/loadScripts: -16%
  • startupStandardHome/numNetworkReqs: -11%
  • startupPowerUserHome/uiStartup: -12%
  • startupPowerUserHome/backgroundConnect: +120%
  • startupPowerUserHome/numNetworkReqs: +14%
  • startupStandardHome/uiStartup: -13%
  • startupStandardHome/load: -13%
  • startupStandardHome/domContentLoaded: -12%
  • startupStandardHome/backgroundConnect: -35%
  • startupStandardHome/firstReactRender: -24%
  • startupStandardHome/loadScripts: -12%
  • startupStandardHome/numNetworkReqs: -29%
  • startupPowerUserHome/domInteractive: -18%
  • startupPowerUserHome/numNetworkReqs: +49%
  • startupStandardHome/domInteractive: -59%
  • startupStandardHome/initialActions: -38%
  • startupStandardHome/numNetworkReqs: -18%
  • startupPowerUserHome/domInteractive: +14%
  • startupPowerUserHome/backgroundConnect: -21%
  • startupPowerUserHome/setupStore: +17%
  • startupStandardHome/domInteractive: -53%
  • startupStandardHome/backgroundConnect: -17%
  • startupStandardHome/initialActions: -44%
  • startupStandardHome/setupStore: -63%
  • startupPowerUserHome/domInteractive: -16%
  • startupPowerUserHome/backgroundConnect: -25%
  • startupPowerUserHome/firstReactRender: -11%
  • startupPowerUserHome/setupStore: -24%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🔴 startupPowerUserHome/INP: p75 624ms
  • 🔴 startupPowerUserHome/INP: p75 688ms
  • 🟡 startupPowerUserHome/LCP: p75 3.8s
  • 🟡 startupPowerUserHome/LCP: p75 3.6s
User Journey Benchmarks
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟡 [Show logs]
solanaAssetDetails🟡 [Show logs]
importSrpHome🟡 [Show logs]
sendTransactions🟡 [Show logs]
swap🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/srpButtonToSrpForm: -11%
  • onboardingImportWallet/metricsToWalletReadyScreen: -35%
  • onboardingImportWallet/doneButtonToHomeScreen: -75%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +32%
  • onboardingImportWallet/total: -39%
  • onboardingNewWallet/srpButtonToPwForm: +14%
  • onboardingNewWallet/skipBackupToMetricsScreen: -17%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: -18%
  • onboardingNewWallet/doneButtonToAssetList: -35%
  • onboardingNewWallet/total: -29%
  • assetDetails/assetClickToPriceChart: -64%
  • assetDetails/total: -64%
  • solanaAssetDetails/assetClickToPriceChart: -54%
  • solanaAssetDetails/total: -54%
  • importSrpHome/loginToHomeScreen: +11%
  • importSrpHome/openAccountMenuAfterLogin: -68%
  • importSrpHome/homeAfterImportWithNewWallet: -37%
  • importSrpHome/total: -32%
  • sendTransactions/openSendPageFromHome: +114%
  • swap/openSwapPageFromHome: -86%
  • swap/fetchAndDisplaySwapQuotes: +31%
  • swap/total: +13%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/INP: p75 216ms
  • 🟡 assetDetails/FCP: p75 2.4s
  • 🟡 solanaAssetDetails/FCP: p75 2.4s
  • 🟡 importSrpHome/INP: p75 216ms
  • 🟡 importSrpHome/FCP: p75 2.5s
  • 🟡 sendTransactions/INP: p75 216ms
  • 🟡 sendTransactions/FCP: p75 2.4s
  • 🟡 swap/FCP: p75 2.4s
🌐 Dapp Page Load Benchmarks

Current Commit: b438d0c | Date: 4/3/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 984ms (±40ms) 🟢 | historical mean value: 1.03s ⬇️ (historical data)
  • domContentLoaded-> current mean value: 691ms (±37ms) 🟢 | historical mean value: 723ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±9ms) 🟢 | historical mean value: 86ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 984ms 40ms 954ms 1.28s 1.02s 1.28s
domContentLoaded 691ms 37ms 669ms 964ms 718ms 964ms
firstPaint 81ms 9ms 68ms 152ms 92ms 152ms
firstContentfulPaint 81ms 9ms 68ms 152ms 92ms 152ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs
  • background: 58 Bytes (0%)
  • ui: 5 Bytes (0%)
  • common: 20 Bytes (0%)

@DDDDDanica DDDDDanica marked this pull request as ready for review April 3, 2026 11:18
@DDDDDanica DDDDDanica enabled auto-merge April 3, 2026 11:18
Comment thread app/scripts/lib/stream-utils.ts Outdated
Co-authored-by: Jongsun Suh <jongsun.suh@icloud.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

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.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 5, 2026

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 Bot commented Apr 5, 2026

Builds ready [0c2a1f1]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 12 warn · 🔴 0 fail)

Baseline (latest main): f34f804 | Date: 9/10/58222 | Pipeline: 24008405906 | Baseline logs

Interaction Benchmarks
Benchmarkchrome-browserify
loadNewAccount🟡 [Show logs]
confirmTx🟡 [Show logs]
bridgeUserActions🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • loadNewAccount/load_new_account: -18%
  • loadNewAccount/total: -18%
  • bridgeUserActions/bridge_load_asset_picker: +15%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 loadNewAccount/FCP: p75 2.5s
  • 🟡 confirmTx/FCP: p75 2.5s
  • 🟡 bridgeUserActions/FCP: p75 2.5s
Startup Benchmarks
Benchmarkchrome-browserifychrome-webpackfirefox-browserifyfirefox-webpack
startupStandardHome🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]🟢 [Show logs]
startupPowerUserHome🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/uiStartup: -15%
  • startupStandardHome/load: -17%
  • startupStandardHome/domContentLoaded: -19%
  • startupStandardHome/initialActions: +25%
  • startupStandardHome/loadScripts: -22%
  • startupPowerUserHome/uiStartup: -16%
  • startupPowerUserHome/backgroundConnect: +88%
  • startupPowerUserHome/firstReactRender: +11%
  • startupPowerUserHome/setupStore: +39%
  • startupPowerUserHome/numNetworkReqs: +13%
  • startupStandardHome/uiStartup: -12%
  • startupStandardHome/load: -12%
  • startupStandardHome/domContentLoaded: -11%
  • startupStandardHome/backgroundConnect: -34%
  • startupStandardHome/firstReactRender: -24%
  • startupStandardHome/loadScripts: -11%
  • startupStandardHome/numNetworkReqs: -29%
  • startupPowerUserHome/domInteractive: -24%
  • startupPowerUserHome/firstPaint: -11%
  • startupStandardHome/domInteractive: -56%
  • startupStandardHome/initialActions: +25%
  • startupStandardHome/numNetworkReqs: -18%
  • startupPowerUserHome/uiStartup: -11%
  • startupPowerUserHome/backgroundConnect: -30%
  • startupStandardHome/domInteractive: -25%
  • startupStandardHome/initialActions: +11%
  • startupStandardHome/setupStore: -54%
  • startupPowerUserHome/domInteractive: -13%
  • startupPowerUserHome/backgroundConnect: -29%
  • startupPowerUserHome/firstReactRender: -11%
  • startupPowerUserHome/numNetworkReqs: -13%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🔴 startupPowerUserHome/INP: p75 760ms
  • 🔴 startupPowerUserHome/INP: p75 592ms
  • 🟡 startupPowerUserHome/LCP: p75 3.4s
  • 🟡 startupPowerUserHome/INP: p75 232ms
  • 🟡 startupPowerUserHome/LCP: p75 3.6s
User Journey Benchmarks
Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
assetDetails🟡 [Show logs]
solanaAssetDetails🟡 [Show logs]
importSrpHome🟡 [Show logs]
sendTransactions🟡 [Show logs]
swap🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • onboardingImportWallet/pwFormToMetricsScreen: +22%
  • onboardingImportWallet/doneButtonToHomeScreen: -75%
  • onboardingImportWallet/openAccountMenuToAccountListLoaded: +42%
  • onboardingImportWallet/total: -41%
  • onboardingNewWallet/createPwToRecoveryScreen: +12%
  • onboardingNewWallet/skipBackupToMetricsScreen: -15%
  • onboardingNewWallet/agreeButtonToOnboardingSuccess: +45%
  • onboardingNewWallet/doneButtonToAssetList: -32%
  • onboardingNewWallet/total: -27%
  • assetDetails/assetClickToPriceChart: -65%
  • assetDetails/total: -65%
  • solanaAssetDetails/assetClickToPriceChart: -59%
  • solanaAssetDetails/total: -59%
  • importSrpHome/loginToHomeScreen: +27%
  • importSrpHome/openAccountMenuAfterLogin: -67%
  • importSrpHome/homeAfterImportWithNewWallet: -29%
  • importSrpHome/total: -22%
  • sendTransactions/openSendPageFromHome: +168%
  • sendTransactions/total: +13%
  • swap/openSwapPageFromHome: -85%
  • swap/fetchAndDisplaySwapQuotes: +31%
  • swap/total: +14%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🟡 assetDetails/INP: p75 232ms
  • 🟡 assetDetails/FCP: p75 2.6s
  • 🟡 solanaAssetDetails/FCP: p75 2.7s
  • 🟡 importSrpHome/INP: p75 264ms
  • 🟡 importSrpHome/FCP: p75 2.9s
  • 🟡 sendTransactions/INP: p75 216ms
  • 🟡 sendTransactions/FCP: p75 2.5s
  • 🟡 swap/FCP: p75 2.5s
🌐 Dapp Page Load Benchmarks

Current Commit: 0c2a1f1 | Date: 4/5/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±147ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±146ms) 🟢 | historical mean value: 728ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 95ms (±125ms) 🟢 | historical mean value: 86ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 147ms 996ms 2.48s 1.08s 2.48s
domContentLoaded 732ms 146ms 696ms 2.16s 769ms 2.16s
firstPaint 95ms 125ms 64ms 1.34s 100ms 1.34s
firstContentfulPaint 95ms 125ms 64ms 1.34s 100ms 1.34s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 58 Bytes (0%)
  • ui: 10.28 KiB (0.12%)
  • common: 2.42 KiB (0.02%)

@DDDDDanica DDDDDanica added this pull request to the merge queue Apr 7, 2026
Merged via the queue into main with commit ce83d28 Apr 7, 2026
207 checks passed
@DDDDDanica DDDDDanica deleted the copilot/convert-stream-utils-to-typescript branch April 7, 2026 20:35
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 7, 2026
@metamaskbot metamaskbot added the release-13.27.0 Issue or pull request that will be included in release 13.27.0 label Apr 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants