Skip to content

fix: skip unnecessary network reset during emulation restore#1891

Closed
dhananjay6561 wants to merge 3 commits into
ChromeDevTools:mainfrom
dhananjay6561:fix/lighthouse-network-timeout-restore
Closed

fix: skip unnecessary network reset during emulation restore#1891
dhananjay6561 wants to merge 3 commits into
ChromeDevTools:mainfrom
dhananjay6561:fix/lighthouse-network-timeout-restore

Conversation

@dhananjay6561
Copy link
Copy Markdown

solves #1797

Summary

Fixes a Lighthouse audit failure where Network.emulateNetworkConditions could hang during emulation restore.

Root cause

lighthouse_audit always runs restoreEmulation() in a finally block.
During restore, McpContext.emulate() always called page.emulateNetworkConditions(null) when networkConditions was not set.
On some Chrome/CDP combinations, that reset call can time out even though no network emulation was active.

What changed

  • Added an internal skipNetworkReset option to McpContext.emulate().
  • Updated restoreEmulation() to skip the network reset when the page had no saved networkConditions.
  • Kept all other emulation restore behavior unchanged.

Validation

  • npm run test:no-build -- tests/McpContext.test.ts
  • npm run test:no-build -- tests/tools/lighthouse.test.ts

Risk

Low. The change only avoids one unnecessary network-reset call when there was nothing to reset.

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Apr 17, 2026

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.

@dhananjay6561 dhananjay6561 changed the title Skip unnecessary network reset during emulation restore fix: skip unnecessary network reset during emulation restore Apr 17, 2026
@dhananjay6561
Copy link
Copy Markdown
Author

@Lightning00Blade hi!
kindly review the pr!

@OrKoN OrKoN requested a review from zyzyzyryxy April 20, 2026 11:56
@dhananjay6561
Copy link
Copy Markdown
Author

@zyzyzyryxy kindly review!

@zyzyzyryxy
Copy link
Copy Markdown
Contributor

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 Network.setUserAgentOverride instead of Network.emulateNetworkConditions

@dhananjay6561
Copy link
Copy Markdown
Author

@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.

@zyzyzyryxy
Copy link
Copy Markdown
Contributor

@dhananjay6561

updated restore logic to skip all unspecified reset calls when there’s nothing to restore [...]

Sorry, I don't see this update, only merges from main. Please double check you did push correctly.

@wolfib
Copy link
Copy Markdown
Contributor

wolfib commented May 18, 2026

#1797 has been fixed

@wolfib wolfib closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants