-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: gracefully end sub-stream on port disconnect to prevent Premature close error #33470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Collaborator
Builds ready [eb7c3ae]
UI Startup Metrics (1236 ± 63 ms)
Benchmark value 1072 exceeds gate value 1070 for chrome browserify home mean load Benchmark value 1065 exceeds gate value 1061 for chrome browserify home mean domContentLoaded Benchmark value 35 exceeds gate value 32 for chrome webpack home mean setupStore Benchmark value 2643 exceeds gate value 2454 for chrome webpack home p95 uiStartup Benchmark value 2171 exceeds gate value 2030 for chrome webpack home p95 load Benchmark value 2161 exceeds gate value 2005 for chrome webpack home p95 domContentLoaded Benchmark value 344 exceeds gate value 334 for chrome webpack home p95 firstPaint Benchmark value 2146 exceeds gate value 1970 for chrome webpack home p95 loadScripts Benchmark value 286 exceeds gate value 65 for chrome webpack home p95 setupStore Benchmark value 14 exceeds gate value 11 for firefox browserify home mean getState Benchmark value 10 exceeds gate value 9 for firefox browserify home mean setupStore Benchmark value 1697 exceeds gate value 1660 for firefox browserify home p95 uiStartup Benchmark value 38 exceeds gate value 24 for firefox browserify home p95 getState Benchmark value 28 exceeds gate value 27 for firefox browserify home p95 setupStore Benchmark value 42 exceeds gate value 38 for firefox webpack home mean firstReactRender Benchmark value 1668 exceeds gate value 1660 for firefox webpack home p95 load Benchmark value 1668 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded Benchmark value 1652 exceeds gate value 1630 for firefox webpack home p95 loadScripts Sum of mean exceeds: 20ms | Sum of p95 exceeds: 983ms Sum of all benchmark exceeds: 1003ms Bundle size diffs [🚀 Bundle size reduced!]
|
Prithpal-Sooriya
approved these changes
Jun 4, 2025
bergarces
approved these changes
Jun 4, 2025
Collaborator
Builds ready [2d2c797]
UI Startup Metrics (1215 ± 62 ms)
Benchmark value 38 exceeds gate value 32 for chrome webpack home mean setupStore Benchmark value 2561 exceeds gate value 2454 for chrome webpack home p95 uiStartup Benchmark value 299 exceeds gate value 65 for chrome webpack home p95 setupStore Benchmark value 12 exceeds gate value 11 for firefox browserify home mean getState Benchmark value 42 exceeds gate value 38 for firefox webpack home mean firstReactRender Benchmark value 1952 exceeds gate value 1935 for firefox webpack home p95 uiStartup Sum of mean exceeds: 11ms | Sum of p95 exceeds: 368ms Sum of all benchmark exceeds: 379ms Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Collaborator
Builds ready [29a7955]
UI Startup Metrics (1220 ± 73 ms)
Benchmark value 2231 exceeds gate value 2192 for chrome webpack home mean uiStartup Benchmark value 1760 exceeds gate value 1711 for chrome webpack home mean load Benchmark value 1752 exceeds gate value 1704 for chrome webpack home mean domContentLoaded Benchmark value 1747 exceeds gate value 1699 for chrome webpack home mean loadScripts Benchmark value 34 exceeds gate value 32 for chrome webpack home mean setupStore Benchmark value 2617 exceeds gate value 2454 for chrome webpack home p95 uiStartup Benchmark value 2059 exceeds gate value 2030 for chrome webpack home p95 load Benchmark value 2048 exceeds gate value 2005 for chrome webpack home p95 domContentLoaded Benchmark value 2037 exceeds gate value 1970 for chrome webpack home p95 loadScripts Benchmark value 310 exceeds gate value 65 for chrome webpack home p95 setupStore Benchmark value 28 exceeds gate value 25 for firefox browserify home mean backgroundConnect Benchmark value 13 exceeds gate value 11 for firefox browserify home mean getState Benchmark value 1761 exceeds gate value 1660 for firefox browserify home p95 uiStartup Benchmark value 1533 exceeds gate value 1495 for firefox browserify home p95 load Benchmark value 1533 exceeds gate value 1495 for firefox browserify home p95 domContentLoaded Benchmark value 1398 exceeds gate value 1380 for firefox webpack home mean load Benchmark value 1398 exceeds gate value 1380 for firefox webpack home mean domContentLoaded Benchmark value 42 exceeds gate value 38 for firefox webpack home mean firstReactRender Benchmark value 1379 exceeds gate value 1360 for firefox webpack home mean loadScripts Benchmark value 1700 exceeds gate value 1660 for firefox webpack home p95 load Benchmark value 1700 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded Benchmark value 1682 exceeds gate value 1630 for firefox webpack home p95 loadScripts Sum of mean exceeds: 250ms | Sum of p95 exceeds: 861ms Sum of all benchmark exceeds: 1111ms Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Collaborator
Builds ready [936c2a4]
UI Startup Metrics (1220 ± 69 ms)
Benchmark value 2484 exceeds gate value 2454 for chrome webpack home p95 uiStartup Benchmark value 299 exceeds gate value 65 for chrome webpack home p95 setupStore Benchmark value 1437 exceeds gate value 1405 for firefox browserify home mean uiStartup Benchmark value 1262 exceeds gate value 1245 for firefox browserify home mean load Benchmark value 1262 exceeds gate value 1239 for firefox browserify home mean domContentLoaded Benchmark value 12 exceeds gate value 11 for firefox browserify home mean getState Benchmark value 1242 exceeds gate value 1230 for firefox browserify home mean loadScripts Benchmark value 12 exceeds gate value 9 for firefox browserify home mean setupStore Benchmark value 1873 exceeds gate value 1660 for firefox browserify home p95 uiStartup Benchmark value 1562 exceeds gate value 1495 for firefox browserify home p95 load Benchmark value 1562 exceeds gate value 1495 for firefox browserify home p95 domContentLoaded Benchmark value 37 exceeds gate value 24 for firefox browserify home p95 getState Benchmark value 1538 exceeds gate value 1475 for firefox browserify home p95 loadScripts Benchmark value 41 exceeds gate value 38 for firefox webpack home mean firstReactRender Benchmark value 1979 exceeds gate value 1935 for firefox webpack home p95 uiStartup Benchmark value 1708 exceeds gate value 1660 for firefox webpack home p95 load Benchmark value 1708 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded Benchmark value 1689 exceeds gate value 1630 for firefox webpack home p95 loadScripts Sum of mean exceeds: 91ms | Sum of p95 exceeds: 890ms Sum of all benchmark exceeds: 981ms Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Collaborator
Builds ready [2c3e0d8]
UI Startup Metrics (1250 ± 75 ms)
Benchmark value 1080 exceeds gate value 1070 for chrome browserify home mean load Benchmark value 1073 exceeds gate value 1061 for chrome browserify home mean domContentLoaded Benchmark value 1389 exceeds gate value 1365 for chrome browserify home p95 uiStartup Benchmark value 1207 exceeds gate value 1190 for chrome browserify home p95 load Benchmark value 1190 exceeds gate value 1180 for chrome browserify home p95 domContentLoaded Benchmark value 1196 exceeds gate value 1180 for chrome browserify home p95 firstPaint Benchmark value 23 exceeds gate value 18 for chrome browserify home p95 backgroundConnect Benchmark value 174 exceeds gate value 65 for chrome webpack home p95 setupStore Benchmark value 1678 exceeds gate value 1660 for firefox browserify home p95 uiStartup Benchmark value 1385 exceeds gate value 1380 for firefox webpack home mean load Benchmark value 1385 exceeds gate value 1380 for firefox webpack home mean domContentLoaded Benchmark value 43 exceeds gate value 38 for firefox webpack home mean firstReactRender Benchmark value 1366 exceeds gate value 1360 for firefox webpack home mean loadScripts Benchmark value 2073 exceeds gate value 1935 for firefox webpack home p95 uiStartup Benchmark value 1837 exceeds gate value 1660 for firefox webpack home p95 load Benchmark value 1836 exceeds gate value 1660 for firefox webpack home p95 domContentLoaded Benchmark value 1816 exceeds gate value 1630 for firefox webpack home p95 loadScripts Sum of mean exceeds: 59ms | Sum of p95 exceeds: 876ms Sum of all benchmark exceeds: 935ms Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR improves the resilience of the createCaipStream utility by gracefully handling stream shutdowns triggered by tab or iframe closures. Previously, when a user clicked an external link (e.g., to a help article) from within a MetaMask confirmation popup, the resulting tab load would create a CAIP stream, and when that tab closed, it triggered "Premature close" errors.
The fix listens for low-level portStream termination events (close, end, and onDisconnect) and explicitly ends the CAIP sub-stream, allowing the pipeline to close cleanly. This prevents noisy, non-actionable errors from polluting logs or Sentry reports, without affecting real error detection or functionality.
Related issues
Fixes: #26284
Manual testing steps
Screenshots/Recordings
Before
before.mov
After
after.mov
Pre-merge author checklist
Pre-merge reviewer checklist