grafana/k6 · error
unmarshaling wait for load state
Error message
unmarshaling wait for load state %q: %w
What it means
Returned while parsing WaitForLoadState options when the 'state' value cannot be unmarshaled into a LifecycleEvent: the string is not a recognized lifecycle event name (expected 'load', 'domcontentloaded', 'networkidle'). User-input validation of the options object.
Solutions
- Use one of the accepted states: 'load', 'domcontentloaded' or 'networkidle'
- Check spelling and quoting of the state string
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/frame.go:2040 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/930b52e22e71a486.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/frame.go:2048
return nil, nil //nolint:nilnil
}
return result, nil
}
// WaitForLoadState waits for the given load state to be reached.
// This will unblock if that lifecycle event has already been received.
func (f *Frame) WaitForLoadState(state string, popts *FrameWaitForLoadStateOptions) error {
f.log.Debugf("Frame:WaitForLoadState", "fid:%s furl:%q state:%s", f.ID(), f.URL(), state)
defer f.log.Debugf("Frame:WaitForLoadState:return", "fid:%s furl:%q state:%s", f.ID(), f.URL(), state)
timeoutCtx, timeoutCancel := context.WithTimeout(f.ctx, popts.Timeout)
defer timeoutCancel()
waitUntil := LifecycleEventLoad
if state != "" {
if err := waitUntil.UnmarshalText([]byte(state)); err != nil {
return fmt.Errorf("unmarshaling wait for load state %q: %w", state, err)
}
}
lifecycleEvent, lifecycleEventCancel := createWaitForEventPredicateHandler(
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
}View on GitHub (pinned to 3fcf5388d7)