{"record":{"id":"af8c4d60eabaec59","repo":"grafana/k6","slug":"waiting-for-navigation-w","errorCode":null,"errorMessage":"waiting for navigation: %w","messagePattern":"waiting for navigation: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/element_handle.go","lineNumber":1780,"sourceCode":"\t\t\t\treturn nil, fmt.Errorf(\"checking hit target: %w\", err)\n\t\t\t}\n\t\t}\n\t\t// Are we only \"trialing\" the action but not actually performing\n\t\t// it (ie. running the actionability checks).\n\t\tif opts.Trial {\n\t\t\treturn nil, nil //nolint:nilnil\n\t\t}\n\n\t\tb := NewBarrier()\n\t\th.frame.manager.addBarrier(b)\n\t\tdefer h.frame.manager.removeBarrier(b)\n\t\tif res, err = fn(apiCtx, h, p); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"evaluating pointer action: %w\", err)\n\t\t}\n\t\t// Do we need to wait for navigation to happen\n\t\tif !opts.NoWaitAfter {\n\t\t\tif err = b.Wait(apiCtx); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"waiting for navigation: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\treturn res, nil\n\t}\n\n\treturn func(apiCtx context.Context, resultCh chan any, errCh chan error) {\n\t\tif res, err := retryPointerAction(apiCtx, pointerFn, opts); err != nil {\n\t\t\tselect {\n\t\t\tcase <-apiCtx.Done():\n\t\t\tcase errCh <- err:\n\t\t\t}\n\t\t} else {\n\t\t\tselect {\n\t\t\tcase <-apiCtx.Done():\n\t\t\tcase resultCh <- res:\n\t\t\t}\n\t\t}","sourceCodeStart":1762,"sourceCodeEnd":1798,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/browser/common/element_handle.go#L1762-L1798","documentation":"After a pointer action executes, k6 installs a navigation Barrier around it (unless NoWaitAfter) and waits for any navigation the action triggers. This error means Barrier.Wait failed: the navigation initiated by the click/tap did not complete within the remaining timeout, or the api context was cancelled (iteration ending, page closing).","triggerScenarios":"Click triggers a navigation whose response hangs (slow or stalled backend) so navigation never finishes before timeout; click starts a download rather than a navigation; context cancelled because the VU iteration ended or the page closed while waiting; NoWaitAfter left false (default) on actions not meant to navigate.","commonSituations":"Logout or submit buttons hitting dead endpoints in test environments; slow third-party redirects chains; clicks that trigger file downloads; strict iteration budgets cancelling the wait.","solutions":["If the action is not supposed to navigate, skip the wait: el.click({ noWaitAfter: true })","If navigation is expected but slow, raise the action timeout: el.click({ timeout: '60s' })","Ensure the target endpoint responds (fix/stub the backend or the load it is under)","For downloads, use noWaitAfter and assert the download event instead of a navigation"],"exampleFix":"// before\npage.$('#export').click(); // triggers download, navigation wait times out\n\n// after\npage.$('#export').click({ noWaitAfter: true });","handlingStrategy":"fallback","validationCode":"// decide up front whether the action should navigate\nconst shouldNavigate = true; // set false for downloads/non-navigating buttons\nif (!shouldNavigate) {\n  el.click({ noWaitAfter: true });\n} else {\n  el.click({ timeout: '60s' });\n}","typeGuard":null,"tryCatchPattern":"try {\n  el.click();\n} catch (e) {\n  if (String(e).includes('waiting for navigation')) {\n    el.click({ noWaitAfter: true }); // navigation not required: skip barrier\n  } else {\n    throw e;\n  }\n}","preventionTips":["Use noWaitAfter on buttons that trigger downloads or no navigation","Give navigational clicks a timeout sized to real backend latency","Fix or stub hanging endpoints that the click navigates to"],"tags":["browser","navigation","timeout","pointer-events","download"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}