fix: skip unnecessary network reset during emulation restore#1891
fix: skip unnecessary network reset during emulation restore#1891dhananjay6561 wants to merge 3 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
@Lightning00Blade hi! |
|
@zyzyzyryxy kindly review! |
|
Hello, thank you for your contribution! As described in the bug report comment, this PR doesn't fully fix the issue, just moves the goalpost. With your change I see timeout on |
|
@zyzyzyryxy my prev change avoided the timeout on Network.emulateNetworkConditions, but it still left other restore-time reset calls in place, which is why the failure shifted to Network.setUserAgentOverride. updated restore logic to skip all unspecified reset calls when there’s nothing to restore, instead of only skipping the network reset. That prevents the timeout from just moving to another CDP command. also added a regression test to verify restore does not call setUserAgent in that no-emulation case. |
Sorry, I don't see this update, only merges from main. Please double check you did push correctly. |
|
#1797 has been fixed |
solves #1797
Summary
Fixes a Lighthouse audit failure where
Network.emulateNetworkConditionscould hang during emulation restore.Root cause
lighthouse_auditalways runsrestoreEmulation()in afinallyblock.During restore,
McpContext.emulate()always calledpage.emulateNetworkConditions(null)whennetworkConditionswas not set.On some Chrome/CDP combinations, that reset call can time out even though no network emulation was active.
What changed
skipNetworkResetoption toMcpContext.emulate().restoreEmulation()to skip the network reset when the page had no savednetworkConditions.Validation
npm run test:no-build -- tests/McpContext.test.tsnpm run test:no-build -- tests/tools/lighthouse.test.tsRisk
Low. The change only avoids one unnecessary network-reset call when there was nothing to reset.