{"record":{"id":"930b52e22e71a486","repo":"grafana/k6","slug":"unmarshaling-wait-for-load-state-q-w","errorCode":null,"errorMessage":"unmarshaling wait for load state %q: %w","messagePattern":"unmarshaling wait for load state %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/frame.go","lineNumber":2048,"sourceCode":"\t\treturn nil, nil //nolint:nilnil\n\t}\n\n\treturn result, nil\n}\n\n// WaitForLoadState waits for the given load state to be reached.\n// This will unblock if that lifecycle event has already been received.\nfunc (f *Frame) WaitForLoadState(state string, popts *FrameWaitForLoadStateOptions) error {\n\tf.log.Debugf(\"Frame:WaitForLoadState\", \"fid:%s furl:%q state:%s\", f.ID(), f.URL(), state)\n\tdefer f.log.Debugf(\"Frame:WaitForLoadState:return\", \"fid:%s furl:%q state:%s\", f.ID(), f.URL(), state)\n\n\ttimeoutCtx, timeoutCancel := context.WithTimeout(f.ctx, popts.Timeout)\n\tdefer timeoutCancel()\n\n\twaitUntil := LifecycleEventLoad\n\tif state != \"\" {\n\t\tif err := waitUntil.UnmarshalText([]byte(state)); err != nil {\n\t\t\treturn fmt.Errorf(\"unmarshaling wait for load state %q: %w\", state, err)\n\t\t}\n\t}\n\n\tlifecycleEvent, lifecycleEventCancel := createWaitForEventPredicateHandler(\n\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}","sourceCodeStart":2030,"sourceCodeEnd":2066,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/modules/k6/browser/common/frame.go#L2030-L2066","documentation":"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.","triggerScenarios":"Thrown at internal/js/modules/k6/browser/common/frame.go:2040 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use one of the accepted states: 'load', 'domcontentloaded' or 'networkidle'","Check spelling and quoting of the state string"],"exampleFix":null,"handlingStrategy":"validation","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"}