grafana/k6 · error
waiting for load state
Error message
waiting for load state %q: %w
What it means
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).
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
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame.go:2063 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18).
Data as JSON: /api/errors/609c22f3693715da.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame.go:2071
timeoutCtx,
f,
[]string{EventFrameAddLifecycle},
func(data any) bool {
if le, ok := data.(FrameLifecycleEvent); ok {
return le.Event == waitUntil
}
return false
})
defer lifecycleEventCancel()
if f.hasLifecycleEventFired(waitUntil) {
return nil
}
select {
case <-lifecycleEvent:
case <-timeoutCtx.Done():
return fmt.Errorf("waiting for load state %q: %w", state, ContextErr(timeoutCtx))
}
return nil
}
// WaitForNavigation waits for the given navigation lifecycle event to happen.
// RegExMatcher should be non-nil to be able to test against a URL pattern in the options.
//
//nolint:funlen
func (f *Frame) WaitForNavigation(opts *FrameWaitForNavigationOptions, rm RegExMatcher) (*Response, error) {
f.log.Debugf("Frame:WaitForNavigation",
"fid:%s furl:%s url:%s", f.ID(), f.URL(), opts.URL)
defer f.log.Debugf("Frame:WaitForNavigation:return",
"fid:%s furl:%s", f.ID(), f.URL())
timeoutCtx, timeoutCancel := context.WithTimeout(f.ctx, opts.Timeout)
// Create URL matcher based on the patternView on GitHub (pinned to 3fcf5388d7)