{"record":{"id":"15042a86d78a4f9f","repo":"grafana/k6","slug":"enabling-page-domain-w","errorCode":null,"errorMessage":"enabling page domain: %w","messagePattern":"enabling page domain: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":424,"sourceCode":"\t// it seems to pause the exec of any other action on\n\t// the page. I believe this is an issue in Chromium.\n\taction := cdppage.HandleJavaScriptDialog(false)\n\tif event.Type == cdppage.DialogTypeBeforeunload {\n\t\taction = cdppage.HandleJavaScriptDialog(true)\n\t}\n\n\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\tfs.logger.Errorf(\"FrameSession:onEventJavascriptDialogOpening\", \"failed to dismiss dialog box: %v\", err)\n\t}\n}\n\nfunc (fs *FrameSession) initFrameTree() error {\n\tfs.logger.Debugf(\"NewFrameSession:initFrameTree\",\n\t\t\"sid:%v tid:%v\", fs.session.ID(), fs.targetID)\n\n\taction := cdppage.Enable()\n\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\treturn fmt.Errorf(\"enabling page domain: %w\", err)\n\t}\n\n\tvar frameTree *cdppage.FrameTree\n\tvar err error\n\n\t// Recursively enumerate all existing frames in page to create initial in-memory structures\n\t// used for access and manipulation from JS.\n\taction2 := cdppage.GetFrameTree()\n\tif frameTree, err = action2.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\treturn fmt.Errorf(\"getting page frame tree: %w\", err)\n\t} else if frameTree == nil {\n\t\t// This can happen with very short scripts when we might not have enough\n\t\t// time to initialize properly.\n\t\treturn fmt.Errorf(\"got a nil page frame tree\")\n\t}\n\n\t// Any new frame may have a child frame, not just mainframes.\n\tfs.handleFrameTree(frameTree, fs.isMainFrame())","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame_session.go#L406-L442","documentation":"FrameSession.initFrameTree (frame_session.go:424) first sends Page.enable before reading the frame tree. If Page.enable fails, frame-session initialization stops with this wrapped error. A failure here means the page target is not accepting commands — closed, crashed, or the session was detached — rather than anything wrong with your script.","triggerScenarios":"Initializing a session for a target that chromium is concurrently destroying (page.close() in another task, browser shutdown), chromium crash, or CDP connection loss. Can also appear for iframe child sessions during page teardown.","commonSituations":"Scripts with aggressive page lifecycle churn under load, browser process OOM-killed in CI, or a remote browser closing targets behind k6's back.","solutions":["Serialize page open/close within a VU so targets are not destroyed while being initialized","Check chromium liveness and memory; restart the browser process between iterations if it degrades","If using a remote endpoint, verify the connection is not dropping (websocket proxy timeouts)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const page = browser.newPage();\n} catch (e) {\n  if (/enabling page domain/i.test(String(e))) {\n    // target closed/crashed during init — recreate and retry once\n  }\n}","preventionTips":["Sequence page creation and close() within a VU; avoid concurrent teardown","Monitor chromium health in long suites and restart the process when it degrades"],"tags":["browser","cdp","page","session","infrastructure"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}