grafana/k6 · error
throttling CPU: %w
Error message
throttling CPU: %w
What it means
page.throttleCPU({ rate }) applies a CPUProfile by sending Emulation.setCPUThrottlingRate to the frame's target. This error means the CDP command failed; most commonly because the session/target is invalid at call time, or the browser rejected the rate value.
Source
Thrown at internal/js/modules/k6/browser/common/frame_session.go:1209
if !initial || offline {
if err := fs.networkManager.SetOfflineMode(offline); err != nil {
return fmt.Errorf("updating offline mode for frame %v: %w", fs.targetID, err)
}
}
return nil
}
func (fs *FrameSession) throttleNetwork(networkProfile NetworkProfile) error {
fs.logger.Debugf("NewFrameSession:throttleNetwork", "sid:%v tid:%v", fs.session.ID(), fs.targetID)
return fs.networkManager.ThrottleNetwork(networkProfile)
}
func (fs *FrameSession) throttleCPU(cpuProfile CPUProfile) error {
action := emulation.SetCPUThrottlingRate(cpuProfile.Rate)
if err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {
return fmt.Errorf("throttling CPU: %w", err)
}
return nil
}
func (fs *FrameSession) updateRequestInterception(enable bool) error {
fs.logger.Debugf("NewFrameSession:updateRequestInterception",
"sid:%v tid:%v on:%v",
fs.session.ID(),
fs.targetID, enable)
return fs.networkManager.setRequestInterception(enable)
}
func (fs *FrameSession) updateViewport() error {
fs.logger.Debugf("NewFrameSession:updateViewport", "sid:%v tid:%v", fs.session.ID(), fs.targetID)
// other frames don't have viewports and,View on GitHub (pinned to 93accf6570)
Solutions
- Use a positive throttling rate (e.g. { rate: 4 } for a 4x slowdown)
- Apply CPU throttling right after page creation, before navigation, while the target is guaranteed alive
- Retry once after confirming the page is still open
- Check for broader CDP failures in the log that indicate a crashed or disconnected browser
Example fix
// before
await page.goto('https://app.example.com');
await page.throttleCPU({ rate: 4 }); // applied mid-lifecycle
// after
await page.throttleCPU({ rate: 4 });
await page.goto('https://app.example.com'); Defensive patterns
Strategy: validation
Validate before calling
const rate = 4;
if (!(rate > 0)) throw new Error('cpu rate must be positive');
if (!page.isClosed()) { await page.throttleCPU({ rate }); } Prevention
- Apply throttling before navigation, right after page creation
- Use positive rate multipliers only
- Keep the browser alive and healthy; investigate if throttling errors appear with other CDP failures
When it happens
Trigger: Calling page.throttleCPU (mapped in page_mapping.go) with a rate when the page is closing/closed or the DevTools session dropped; or passing a rate the browser will not accept (zero or negative multiplier).
Common situations: Performance tests throttling CPU to emulate low-end devices; applying throttling late in the iteration; headed browsers in CI crashing; version drift after renaming/moving throttling APIs.
Related errors
- WebSocket endpoint cannot be empty
- can't fetch the page for unknown reason
- errorText
- parent frame has been detached
- adding k6 object to new browser context: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/ce22377067330a7c.
Report an issue: GitHub.