Skip to content

fix: skip unnecessary network reset during emulation restore#1891

Open
dhananjay6561 wants to merge 2 commits intoChromeDevTools:mainfrom
dhananjay6561:fix/lighthouse-network-timeout-restore
Open

fix: skip unnecessary network reset during emulation restore#1891
dhananjay6561 wants to merge 2 commits intoChromeDevTools: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
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.

1 participant