{"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":1267,"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(ctx context.Context, emulatedSize *EmulatedSize) 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":1249,"sourceCodeEnd":1285,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame_session.go#L1249-L1285","documentation":"Wrap of the CDP Emulation.setCPUThrottlingRate command: throttleCPU sends the configured CPUProfile.Rate to the browser to slow down the page's main thread. The wrapped error surfaces when the CDP command cannot be executed — the session or context was canceled (test iteration ending), the target is gone, or the rate is outside what the browser accepts (e.g., zero or negative).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame_session.go:1209 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a positive CPU throttling rate (e.g., 4 for 4x slowdown)","Ensure the browser session is still alive and the page target exists when applying CPU throttling","Apply throttling through context/page options before heavy navigation rather than mid-teardown","Update to the latest k6 browser module and bundled Chromium"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}