{"record":{"id":"fa4ef2bb27e3f43f","repo":"grafana/k6","slug":"getting-browser-window-id-w","errorCode":null,"errorMessage":"getting browser window ID: %w","messagePattern":"getting browser window ID: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":184,"sourceCode":"\tif err != nil {\n\t\tl.Debugf(\"NewFrameSession:NewNetworkManager\", \"sid:%v tid:%v err:%v\",\n\t\t\ts.ID(), tid, err)\n\t\treturn nil, err\n\t}\n\n\t// When a frame creates a new FrameSession without UI (e.g. some iframes) we cannot\n\t// retrieve the windowID. Doing so would lead to an error from chromium. For now all\n\t// iframes that are attached are setup with hasUIWindow as false which seems to work\n\t// as expected for iframes with and without UI elements.\n\tif fs.hasUIWindow {\n\t\taction := browser.GetWindowForTarget().WithTargetID(fs.targetID)\n\t\tif fs.windowID, _, err = action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\t\tl.Debugf(\n\t\t\t\t\"NewFrameSession:GetWindowForTarget\",\n\t\t\t\t\"sid:%v tid:%v err:%v\",\n\t\t\t\ts.ID(), tid, err)\n\n\t\t\treturn nil, fmt.Errorf(\"getting browser window ID: %w\", err)\n\t\t}\n\t}\n\n\tfs.initEvents()\n\tif err = fs.initFrameTree(); err != nil {\n\t\tl.Debugf(\n\t\t\t\"NewFrameSession:initFrameTree\",\n\t\t\t\"sid:%v tid:%v err:%v\",\n\t\t\ts.ID(), tid, err)\n\n\t\treturn nil, err\n\t}\n\tif err = fs.initIsolatedWorld(utilityWorldName); err != nil {\n\t\tl.Debugf(\n\t\t\t\"NewFrameSession:initIsolatedWorld\",\n\t\t\t\"sid:%v tid:%v err:%v\",\n\t\t\ts.ID(), tid, err)\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame_session.go#L166-L202","documentation":"During NewFrameSession for a frame with a UI window, the Browser.getWindowForTarget CDP call failed, so the browser window ID could not be retrieved. The wrapped error is Chromium's; without the window ID the frame session cannot be fully initialized.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame_session.go:155 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped CDP error for the concrete Chromium failure","Ensure the browser window exists and wasn't closed/minimized away unexpectedly","Update k6 and Chromium; report to grafana/k6 if persistent"],"exampleFix":null,"handlingStrategy":"try-catch","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"}