{"record":{"id":"04db8e3b6924e483","repo":"grafana/k6","slug":"q-is-not-a-valid-lifecycle","errorCode":null,"errorMessage":"%q is not a valid lifecycle","messagePattern":"%q is not a valid lifecycle","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/common/page_options.go","lineNumber":81,"sourceCode":"\t\tTimeout:   defaultTimeout,\n\t}\n}\n\n// Parse parses the page go back/forward options.\nfunc (o *PageGoBackForwardOptions) Parse(ctx context.Context, opts sobek.Value) error {\n\tif common.IsNullish(opts) {\n\t\treturn nil\n\t}\n\n\tobj := opts.ToObject(k6ext.Runtime(ctx))\n\tfor _, k := range obj.Keys() {\n\t\tswitch k {\n\t\tcase \"waitUntil\":\n\t\t\tlifeCycle := obj.Get(k).String()\n\t\t\tif l, ok := lifecycleEventToID[lifeCycle]; ok {\n\t\t\t\to.WaitUntil = l\n\t\t\t} else {\n\t\t\t\treturn fmt.Errorf(\"%q is not a valid lifecycle\", lifeCycle)\n\t\t\t}\n\t\tcase \"timeout\":\n\t\t\to.Timeout = time.Duration(obj.Get(k).ToInteger()) * time.Millisecond\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// Parse parses the page reload options.\nfunc (o *PageReloadOptions) Parse(ctx context.Context, opts sobek.Value) error {\n\trt := k6ext.Runtime(ctx)\n\tif !common.IsNullish(opts) {\n\t\topts := opts.ToObject(rt)\n\t\tfor _, k := range opts.Keys() {\n\t\t\tswitch k {\n\t\t\tcase \"waitUntil\":\n\t\t\t\tlifeCycle := opts.Get(k).String()","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/js/modules/k6/browser/common/page_options.go#L63-L99","documentation":"Thrown while parsing page navigation options (PageGotoOptions.Parse) when the waitUntil value is not one of the supported lifecycle names. The parser looks the string up in lifecycleEventToID, which only contains 'load', 'domcontentloaded', and 'networkidle'; anything else is rejected with this quoted-value error. Note Playwright-style values like 'commit' or 'domcontentloaded ' (typo/case) are not supported.","triggerScenarios":"Calling page.goto(url, { waitUntil: 'commit' | 'domContentLoaded' | 'interactive' }) or any non-enum string; copying scripts from Playwright/Puppeteer docs that use lifecycle names k6 does not implement; passing an empty string or wrong case ('Load').","commonSituations":"Migrating Playwright tests to k6 browser (Playwright adds 'commit'); typos and case mismatches; assuming Puppeteer's 'networkidle2' exists — k6 only supports 'networkidle'.","solutions":["Use one of: 'load', 'domcontentloaded', 'networkidle'.","Fix case and spelling — the value is matched exactly, lowercase only.","Replace 'networkidle2' with 'networkidle', and drop Playwright-only 'commit'."],"exampleFix":"// before\nawait page.goto(url, { waitUntil: 'networkidle2' });\n\n// after\nawait page.goto(url, { waitUntil: 'networkidle' });","handlingStrategy":"validation","validationCode":"const LIFECYCLES = ['load', 'domcontentloaded', 'networkidle'];\nif (!LIFECYCLES.includes(waitUntil)) throw new Error(`waitUntil must be one of ${LIFECYCLES.join(', ')}`);\nawait page.goto(url, { waitUntil });","typeGuard":"const isLifecycle = (v) =>\n  v === 'load' || v === 'domcontentloaded' || v === 'networkidle';","tryCatchPattern":null,"preventionTips":["Define the three valid values as script constants and reuse them.","When porting Playwright/Puppeteer scripts, map 'commit'→'domcontentloaded', 'networkidle2'→'networkidle'.","Values are case-sensitive; always lowercase."],"tags":["k6","browser","waituntil","lifecycle","options-validation"],"backgroundTag":"invalid-enum-option","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}