{"record":{"id":"e2a3385aff8bc560","repo":"grafana/k6","slug":"the-page-may-have-navigated-away-or-the-element-is","errorCode":null,"errorMessage":"the page may have navigated away or the element is\n\t\t\tnow missing. It might happen when k6 and/or Chrome are overloaded. You\n\t\t\tmight need to increase the compute resources","messagePattern":"the page may have navigated away or the element is\n\t\t\tnow missing\\. It might happen when k6 and/or Chrome are overloaded\\. You\n\t\t\tmight need to increase the compute resources","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/execution_context.go","lineNumber":111,"sourceCode":"\t\te.sid, e.stid, e.fid, e.id, e.furl, backendNodeID)\n\n\tvar (\n\t\tremoteObj *runtime.RemoteObject\n\t\terr       error\n\t)\n\n\taction := dom.ResolveNode().\n\t\tWithBackendNodeID(backendNodeID).\n\t\tWithExecutionContextID(e.id)\n\n\tif remoteObj, err = action.Do(cdp.WithExecutor(e.ctx, e.session)); err != nil {\n\t\treturn nil, fmt.Errorf(\"resolving DOM node: %w\", err)\n\t}\n\n\t// This can occur due to race conditions between trying to click on an element\n\t// and chrome moving on (e.g. navigating).\n\tif remoteObj == nil {\n\t\treturn nil, fmt.Errorf(`the page may have navigated away or the element is\n\t\t\tnow missing. It might happen when k6 and/or Chrome are overloaded. You\n\t\t\tmight need to increase the compute resources`)\n\t}\n\n\treturn NewJSHandle(e.ctx, e.session, e, e.frame, remoteObj, e.logger).AsElement(), nil\n}\n\n// Adopts the specified element handle into this execution context from another execution context.\nfunc (e *ExecutionContext) adoptElementHandle(eh *ElementHandle) (*ElementHandle, error) {\n\tvar (\n\t\tefid cdp.FrameID\n\t\tesid target.SessionID\n\t)\n\tif eh.frame != nil {\n\t\tefid = cdp.FrameID(eh.frame.ID())\n\t}\n\tif eh.session != nil {\n\t\tesid = eh.session.ID()","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/execution_context.go#L93-L129","documentation":"DOM.resolveNode succeeded but returned no remote object. The code comment states the cause: a race condition between k6 trying to act on an element and Chrome moving on (typically navigating). k6 treats a nil remote object as 'the node disappeared under us' and returns this advisory message, which also notes that k6 and/or Chrome being overloaded can trigger it.","triggerScenarios":"Page navigates between the moment k6 resolves the element's backend node and the moment it materializes an object; the node is removed by a SPA re-render; Chrome is resource-starved and drops the node; the tab closes during the action.","commonSituations":"High-VU runs where a single Chrome instance is CPU/memory bound; slow machines or constrained CI containers running the browser; clicking elements that trigger immediate navigation (form submits, links); lazy loading replacing DOM subtrees.","solutions":["Retry the action: re-query the element and act again — the race is transient","Await the expected navigation (waitForNavigation / waitForLoadState) before further actions","Increase compute for Chrome (more CPU, fewer VUs per browser) if it appears intermittently under load","Let the DOM settle after dynamic updates before interacting"],"exampleFix":"// before\nconst el = await page.$('#link');\nawait el.click();\nawait el.click(); // second click races the navigation\n\n// after\nconst el = await page.$('#link');\nawait Promise.all([page.waitForNavigation(), el.click()]);\nconst el2 = await page.$('#next');\nawait el2.click();","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await el.click();\n} catch (e) {\n  if (/navigated away|now missing/.test(e.message)) {\n    await page.waitForLoadState();\n    el = await page.$('#link');\n    await el.click();\n  } else throw e;\n}","preventionTips":["Pair navigation-triggering actions with waitForNavigation","Re-query elements after any navigation","Provision enough CPU/memory for Chrome under load","Avoid acting on the same handle twice across a navigation boundary"],"tags":["browser","cdp","navigation","race-condition","resources"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}