grafana/k6 · error
invalid lifecycle event
Error message
invalid lifecycle event: %q; must be one of: %s
What it means
Returned by LifecycleEvent.UnmarshalText when the text value is not a recognized lifecycle event name; it is a validation guard that lists all accepted values (load, domcontentloaded, networkidle). The input at fault is the unrecognized event string.
Solutions
- Use one of the valid lifecycle events: load, domcontentloaded, or networkidle
- Check for typos and case sensitivity in the event name in the script
- Parse the error message, which enumerates all valid values, to pick a supported one
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/lifecycle.go:103 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/cf22677ccca9c413.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/lifecycle.go:103
}
// UnmarshalText unmarshals a text representation to the enum value.
// It returns an error if given a wrong value.
func (l *LifecycleEvent) UnmarshalText(text []byte) error {
var (
ok bool
val = string(text)
)
if *l, ok = lifecycleEventToID[val]; !ok {
valid := make([]string, 0, len(lifecycleEventToID))
for k := range lifecycleEventToID {
valid = append(valid, k)
}
sort.Slice(valid, func(i, j int) bool {
return lifecycleEventToID[valid[j]] > lifecycleEventToID[valid[i]]
})
return fmt.Errorf(
"invalid lifecycle event: %q; must be one of: %s",
val, strings.Join(valid, ", "))
}
return nil
}
View on GitHub (pinned to 01ffac6f24)