Skip to content

fix: Apply CPU throttling to secondary CDP session#2092

Open
wolfib wants to merge 2 commits into
mainfrom
extend-navigation-timeout
Open

fix: Apply CPU throttling to secondary CDP session#2092
wolfib wants to merge 2 commits into
mainfrom
extend-navigation-timeout

Conversation

@wolfib
Copy link
Copy Markdown
Contributor

@wolfib wolfib commented May 20, 2026

This addresses #1955

CPU throttling needs to be applied to both the primary puppeteer session and the secondary CDP session from the DevTools universe to have an effect.

For network throttling this does not seem to be the case, I can see a slowdown with the current implementation which only applies the network throttling to the primary CDP session.

I also had to increase the navigation timeout to prevent timeout errors.

@wolfib wolfib force-pushed the extend-navigation-timeout branch from 0694532 to c09351b Compare May 20, 2026 15:40
@wolfib wolfib requested a review from OrKoN May 20, 2026 17:19
Comment thread src/McpContext.ts
const secondarySession = this.getDevToolsUniverse(mcpPage)?.session;
if (!options.cpuThrottlingRate) {
await page.emulateCPUThrottling(1);
if (secondarySession) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am surprised this is needed because CPUthrottling is global IIRC. Are we sure DevTools code does not reset CPU throttling upon instantiation?

});
});

it('applies cpu throttling to secondary session', async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we test instead that throttling apply correctly to performance trace results?

Copy link
Copy Markdown
Collaborator

@OrKoN OrKoN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as a temporary solution but let's fix it upstream and file a task to clean up.

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.

2 participants