{"record":{"id":"2a57f1048fd50cda","repo":"grafana/k6","slug":"internal-error-while-enabling-t-w","errorCode":null,"errorMessage":"internal error while enabling %T: %w","messagePattern":"internal error while enabling %T: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame_session.go","lineNumber":232,"sourceCode":"\t}\n\treturn nil\n}\n\nfunc (fs *FrameSession) getNetworkManager() *NetworkManager {\n\treturn fs.networkManager\n}\n\nfunc (fs *FrameSession) initDomains() error {\n\tactions := []Action{\n\t\t// TODO: can we get rid of the following by doing DOM related stuff in JS instead?\n\t\tdom.Enable(),\n\t\tcdplog.Enable(),\n\t\tcdpruntime.Enable(),\n\t\ttarget.SetAutoAttach(true, true).WithFlatten(true),\n\t}\n\tfor _, action := range actions {\n\t\tif err := action.Do(cdp.WithExecutor(fs.ctx, fs.session)); err != nil {\n\t\t\treturn fmt.Errorf(\"internal error while enabling %T: %w\", action, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n//nolint:cyclop\nfunc (fs *FrameSession) initEvents() {\n\tfs.logger.Debugf(\"NewFrameSession:initEvents\",\n\t\t\"sid:%v tid:%v\", fs.session.ID(), fs.targetID)\n\n\tevents := []string{\n\t\tcdproto.EventInspectorTargetCrashed,\n\t}\n\tfs.session.on(fs.ctx, events, fs.eventCh)\n\tif !fs.isMainFrame() {\n\t\tfs.initRendererEvents()\n\t}\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/frame_session.go#L214-L250","documentation":"FrameSession.initDomains (frame_session.go:232) enables the base CDP domains for a new target — DOM.enable, Log.enable, Runtime.enable and Target.setAutoAttach(flatten). Any failure is wrapped with the concrete action type (%T). Because these are foundational commands, failure means the CDP session/target is dead or the protocol is incompatible, not that the page content is bad.","triggerScenarios":"Chromium crash/OOM kill at the moment a page or iframe target attaches, target already closed (session torn down) during rapid page churn, or a remote browser whose CDP version rejects one of these commands.","commonSituations":"High VU counts exhausting memory so chromium dies mid-attach, k6 driving a much older/newer chromium than supported, or flaky websocket endpoints for remote browsers.","solutions":["Stabilize chromium resources: more memory, fewer concurrent pages/VUs, restart browser per iteration if needed","Check the wrapped %T action and the underlying CDP error to see which domain failed; a version mismatch usually points at Target.setAutoAttach","Use the chromium bundled with/expected by your k6 version; avoid mixing k6 with arbitrary remote browser builds"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const page = browser.newPage();\n} catch (e) {\n  if (/internal error while enabling/i.test(String(e))) {\n    // CDP session died during domain init — retry page creation on a fresh context\n  }\n}","preventionTips":["Cap concurrent pages per VU to keep chromium within memory limits","Check dmesg/OOM logs when this error appears intermittently","Match k6 and chromium versions — avoid arbitrary remote browser builds"],"tags":["browser","cdp","domains","crash","infrastructure"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}