{"record":{"id":"ce22377067330a7c","repo":"grafana/k6","slug":"throttling-cpu-w","errorCode":null,"errorMessage":"throttling CPU: %w","messagePattern":"throttling CPU: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":1209,"sourceCode":"\tif !initial || offline {\n\t\tif err := fs.networkManager.SetOfflineMode(offline); err != nil {\n\t\t\treturn fmt.Errorf(\"updating offline mode for frame %v: %w\", fs.targetID, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (fs *FrameSession) throttleNetwork(networkProfile NetworkProfile) error {\n\tfs.logger.Debugf(\"NewFrameSession:throttleNetwork\", \"sid:%v tid:%v\", fs.session.ID(), fs.targetID)\n\n\treturn fs.networkManager.ThrottleNetwork(networkProfile)\n}\n\nfunc (fs *FrameSession) throttleCPU(cpuProfile CPUProfile) error {\n\taction := emulation.SetCPUThrottlingRate(cpuProfile.Rate)\n\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\treturn fmt.Errorf(\"throttling CPU: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc (fs *FrameSession) updateRequestInterception(enable bool) error {\n\tfs.logger.Debugf(\"NewFrameSession:updateRequestInterception\",\n\t\t\"sid:%v tid:%v on:%v\",\n\t\tfs.session.ID(),\n\t\tfs.targetID, enable)\n\n\treturn fs.networkManager.setRequestInterception(enable)\n}\n\nfunc (fs *FrameSession) updateViewport() error {\n\tfs.logger.Debugf(\"NewFrameSession:updateViewport\", \"sid:%v tid:%v\", fs.session.ID(), fs.targetID)\n\n\t// other frames don't have viewports and,","sourceCodeStart":1191,"sourceCodeEnd":1227,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame_session.go#L1191-L1227","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nawait page.goto('https://app.example.com');\nawait page.throttleCPU({ rate: 4 }); // applied mid-lifecycle\n\n// after\nawait page.throttleCPU({ rate: 4 });\nawait page.goto('https://app.example.com');","handlingStrategy":"validation","validationCode":"const rate = 4;\nif (!(rate > 0)) throw new Error('cpu rate must be positive');\nif (!page.isClosed()) { await page.throttleCPU({ rate }); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["browser","performance","cpu-throttling","cdp"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}