{"record":{"id":"77fde1b4f3706610","repo":"grafana/k6","slug":"internal-error-while-auto-attaching-to-browser-pag-77fde1","errorCode":null,"errorMessage":"internal error while auto attaching to browser pages: %w","messagePattern":"internal error while auto attaching to browser pages: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page.go","lineNumber":356,"sourceCode":"\tp.frameManager = NewFrameManager(ctx, s, &p, p.timeoutSettings, p.logger)\n\tp.mainFrameSession, err = NewFrameSession(p.ctx, p.teardownCtx, s, &p, nil, tid, p.logger, true)\n\tif err != nil {\n\t\tp.logger.Debugf(\"Page:NewPage:NewFrameSession:return\", \"sid:%v tid:%v err:%v\",\n\t\t\tp.sessionID(), tid, err)\n\n\t\treturn nil, err\n\t}\n\tp.frameSessionsMu.Lock()\n\tp.frameSessions[cdp.FrameID(tid)] = p.mainFrameSession\n\tp.frameSessionsMu.Unlock()\n\tp.Mouse = NewMouse(ctx, s, p.frameManager.MainFrame(), bctx.timeoutSettings, p.Keyboard)\n\tp.Touchscreen = NewTouchscreen(ctx, s, p.Keyboard)\n\n\tp.initEvents()\n\n\taction := target.SetAutoAttach(true, true).WithFlatten(true)\n\tif err := action.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil {\n\t\treturn nil, fmt.Errorf(\"internal error while auto attaching to browser pages: %w\", err)\n\t}\n\n\tadd := runtime.AddBinding(webVitalBinding)\n\tif err := add.Do(cdp.WithExecutor(p.ctx, p.session)); err != nil {\n\t\treturn nil, fmt.Errorf(\"internal error while adding binding to page: %w\", err)\n\t}\n\n\tif err := bctx.applyAllInitScripts(&p); err != nil {\n\t\treturn nil, fmt.Errorf(\"internal error while applying init scripts to page: %w\", err)\n\t}\n\n\treturn &p, nil\n}\n\nfunc (p *Page) initEvents() {\n\tp.logger.Debugf(\"Page:initEvents\",\n\t\t\"sid:%v tid:%v\", p.session.ID(), p.targetID)\n","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/page.go#L338-L374","documentation":"Failure of the CDP target.setAutoAttach command (with flatten) during page creation, which makes the browser auto-attach to new child targets (iframes/popups). Marked 'internal' because the user cannot influence it directly; it fires when the DevTools session rejects the command during page setup.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/page.go:354 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry page/browser creation — usually a transient CDP startup race","Verify browser launch succeeded and is not resource-starved","Report as a k6/browser bug if it reproduces reliably on a healthy browser"],"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"}