{"record":{"id":"5d86bf90cd4ca06d","repo":"grafana/k6","slug":"getting-remote-node-q-w","errorCode":null,"errorMessage":"getting remote node %q: %w","messagePattern":"getting remote node %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":859,"sourceCode":"\t\t&opts.ElementHandleBasePointerOptions,\n\t)\n\tif _, err := call(h.ctx, click, opts.Timeout); err != nil {\n\t\treturn fmt.Errorf(\"clicking on element: %w\", err)\n\t}\n\tapplySlowMo(h.ctx)\n\n\treturn nil\n}\n\n// ContentFrame returns the frame that contains this element.\nfunc (h *ElementHandle) ContentFrame() (*Frame, error) {\n\tvar (\n\t\tnode *cdp.Node\n\t\terr  error\n\t)\n\taction := dom.DescribeNode().WithObjectID(h.remoteObject.ObjectID)\n\tif node, err = action.Do(cdp.WithExecutor(h.ctx, h.session)); err != nil {\n\t\treturn nil, fmt.Errorf(\"getting remote node %q: %w\", h.remoteObject.ObjectID, err)\n\t}\n\tif node == nil || node.FrameID == \"\" {\n\t\treturn nil, fmt.Errorf(\"element is not an iframe\")\n\t}\n\n\tframe, ok := h.frame.manager.getFrameByID(node.FrameID)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"frame not found for id %s\", node.FrameID)\n\t}\n\n\treturn frame, nil\n}\n\n// Dblclick scrolls element into view and double clicks on the element.\nfunc (h *ElementHandle) Dblclick(opts *ElementHandleDblclickOptions) error {\n\tdblclick := func(_ context.Context, handle *ElementHandle, p *Position) (any, error) {\n\t\treturn nil, handle.dblclick(p, opts.ToMouseClickOptions())\n\t}","sourceCodeStart":841,"sourceCodeEnd":877,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L841-L877","documentation":"ContentFrame() runs CDP DOM.describeNode on the handle's remote object; this error wraps a protocol-level failure — typically an invalid/stale objectID ('Cannot find context element' style), a closed CDP session, or a dead target.","triggerScenarios":"handle.contentFrame() (or frame-crossing selector resolution reaching it) on a handle whose node was removed, after navigation invalidated objectIDs, or when the browser session/target died.","commonSituations":"ElementHandles stored across navigations; out-of-process iframe teardown races; browser crash/OOM; slow pages where the handle outlives its context.","solutions":["Re-query the element and call contentFrame() immediately after locating it","Avoid caching handles across navigations; re-resolve per action","Check browser/session health if the wrapped error mentions closed targets","Increase the surrounding timeout so iframe attachment completes first"],"exampleFix":"// before\nawait storedHandle.contentFrame(); // getting remote node: ... \n\n// after\nconst iframeEl = await page.$('#myframe');\nconst frame = await iframeEl.contentFrame();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const frame = await handle.contentFrame();\n} catch (e) {\n  if (String(e).includes('getting remote node')) {\n    handle = await page.$(sel); // fresh objectID\n    return await handle.contentFrame();\n  }\n  throw e;\n}","preventionTips":["Call contentFrame() immediately after locating the iframe","Never cache handles across navigations","Investigate browser health if wrapped errors mention closed targets"],"tags":["browser","iframe","cdp","stale-handle"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}