ci: Fix flaky E2E failures from ERR_BLOCKED_BY_CLIENT extension ID race condition#40358
Draft
ci: Fix flaky E2E failures from ERR_BLOCKED_BY_CLIENT extension ID race condition#40358
ERR_BLOCKED_BY_CLIENT extension ID race condition#40358Conversation
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. |
ERR_BLOCKED_BY_CLIENT console errorsERR_BLOCKED_BY_CLIENT console errors
ERR_BLOCKED_BY_CLIENT console errorsERR_BLOCKED_BY_CLIENT errors in E2E tests
ERR_BLOCKED_BY_CLIENT errors in E2E testsERR_BLOCKED_BY_CLIENT errors in E2E tests
Contributor
Builds ready [88c32ff]
⚡ Performance Benchmarks (1374 ± 111 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
- Add retry logic (5x, 1s delay) to `getExtensionIdByName` shadow DOM query to handle race condition when `chrome://extensions` hasn't fully loaded - Add null guard in `mock-e2e.js` `beforeRequest` handler to return 200 for requests with null/undefined host or URL - Add `net::ERR_BLOCKED_BY_CLIENT` and `null is blocked` to default `ignoredConsoleErrors` in `driver.js`
88c32ff to
26c869c
Compare
Contributor
✨ Files requiring CODEOWNER review ✨🧪 @MetaMask/qa (1 files, +7 -0)
|
|
ERR_BLOCKED_BY_CLIENT errors in E2E testsERR_BLOCKED_BY_CLIENT extension ID race condition
Contributor
Builds ready [26c869c]
⚡ Performance Benchmarks (1359 ± 97 ms)
🌐 Dapp Page Load BenchmarksCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Fixes three related causes of flaky E2E test failures involving null URLs and extension ID resolution.
Impact Overview
These three fixes address a single failure chain that produces non-deterministic E2E failures:
Because the root cause is a race condition (extension page load timing vs. shadow DOM query), these failures are inherently flaky — they pass on retry but pollute CI signal and waste re-run budget. The fix addresses all three layers:
chrome.jsundefinedbefore page loads, serialized asnullby WebDrivermock-e2e.jsbeforeRequesthandler assumeshost/urlare always defined; null values fall through unpredictablydriver.jscheckBrowserForConsoleErrorscapturesERR_BLOCKED_BY_CLIENTandnull is blockedas test failuresignoredConsoleErrorsEstimated impact on E2E runs: When the extension ID resolves to null, every subsequent page navigation in that test run fails — it's not a single-assertion failure but a full test abort. Because the root cause is a page load race condition, these failures are non-deterministic: they pass on retry but waste CI compute on re-runs and obscure real regressions in the signal. The retry logic eliminates the race at its source. The mock server guard and console error ignore provide defense-in-depth for edge cases where null URLs still reach the proxy.
Discovered during E2E benchmark profiling runs for the P0 cascade re-render fixes.
1. Retry logic for extension ID resolution (
chrome.js)getExtensionIdByNamequeries thechrome://extensionsshadow DOM to find the MetaMask extension ID. If the page or extension hasn't fully loaded, the query silently returnsundefined(serialized asnullby WebDriver), causing all subsequent navigation to go tochrome-extension://null/home.html— which Chrome blocks withERR_BLOCKED_BY_CLIENT.Fix: Retry the shadow DOM query up to 5 times with 1s delay, wrapped in try/catch to handle partial page loads gracefully.
2. Null guard in mock server (
mock-e2e.js)The
forAnyRequest().thenPassThrough()beforeRequesthandler assumedhostandurlare always defined. Requests with null/undefined values would fall through to the blocklist/allowlist checks unpredictably.Fix: Early return with a 200 response when
hostorurlis null/undefined.3. Ignore
ERR_BLOCKED_BY_CLIENTconsole errors (driver.js)Chrome blocks requests to null/invalid URLs at the browser level before they reach the proxy, logging
net::ERR_BLOCKED_BY_CLIENTandnull is blockedas console errors. These get captured bycheckBrowserForConsoleErrorsand cause test failures.Fix: Added both patterns to the default
ignoredConsoleErrorslist.Changelog
CHANGELOG entry: null
Related issues
N/A — discovered during E2E benchmark profiling runs.
Manual testing steps
chrome-extension://null/navigations)ERR_BLOCKED_BY_CLIENTerrors cause test failuresPre-merge author checklist