{"record":{"id":"609c22f3693715da","repo":"grafana/k6","slug":"waiting-for-load-state-q-w","errorCode":null,"errorMessage":"waiting for load state %q: %w","messagePattern":"waiting for load state %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":2071,"sourceCode":"\t\ttimeoutCtx,\n\t\tf,\n\t\t[]string{EventFrameAddLifecycle},\n\t\tfunc(data any) bool {\n\t\t\tif le, ok := data.(FrameLifecycleEvent); ok {\n\t\t\t\treturn le.Event == waitUntil\n\t\t\t}\n\t\t\treturn false\n\t\t})\n\tdefer lifecycleEventCancel()\n\n\tif f.hasLifecycleEventFired(waitUntil) {\n\t\treturn nil\n\t}\n\n\tselect {\n\tcase <-lifecycleEvent:\n\tcase <-timeoutCtx.Done():\n\t\treturn fmt.Errorf(\"waiting for load state %q: %w\", state, ContextErr(timeoutCtx))\n\t}\n\n\treturn nil\n}\n\n// WaitForNavigation waits for the given navigation lifecycle event to happen.\n// RegExMatcher should be non-nil to be able to test against a URL pattern in the options.\n//\n//nolint:funlen\nfunc (f *Frame) WaitForNavigation(opts *FrameWaitForNavigationOptions, rm RegExMatcher) (*Response, error) {\n\tf.log.Debugf(\"Frame:WaitForNavigation\",\n\t\t\"fid:%s furl:%s url:%s\", f.ID(), f.URL(), opts.URL)\n\tdefer f.log.Debugf(\"Frame:WaitForNavigation:return\",\n\t\t\"fid:%s furl:%s\", f.ID(), f.URL())\n\n\ttimeoutCtx, timeoutCancel := context.WithTimeout(f.ctx, opts.Timeout)\n\n\t// Create URL matcher based on the pattern","sourceCodeStart":2053,"sourceCodeEnd":2089,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L2053-L2089","documentation":"Returned by Frame.WaitForLoadState when the requested lifecycle event does not fire before the options timeout expires: the select on the lifecycle event channel lost to timeoutCtx.Done(). ContextErr reports whether it was deadline or cancellation. The event may also never fire (e.g. networkidle on chatty pages).","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:2063 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase the timeout option","Prefer 'load' or 'domcontentloaded' over 'networkidle' for pages with constant network traffic","Wait after the state already fired is a no-op; ensure you wait for the right frame"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}