{"record":{"id":"9c8fa4bad981067d","repo":"grafana/k6","slug":"parsing-goto-options-w-frame-mapping","errorCode":null,"errorMessage":"parsing goto options: %w","messagePattern":"parsing goto options: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/frame_mapping.go","lineNumber":737,"sourceCode":"// parseFrameGotoOptions parses the frame goto options from a Sobek value.\nfunc parseFrameGotoOptions(\n\trt *sobek.Runtime, opts sobek.Value, defaultReferrer string, defaultTimeout time.Duration,\n) (*common.FrameGotoOptions, error) {\n\tgopts := common.NewFrameGotoOptions(defaultReferrer, defaultTimeout)\n\tif k6common.IsNullish(opts) {\n\t\treturn gopts, nil\n\t}\n\tobj := opts.ToObject(rt)\n\tfor _, k := range obj.Keys() {\n\t\tswitch k {\n\t\tcase \"referer\":\n\t\t\tgopts.Referer = obj.Get(k).String()\n\t\tcase \"timeout\":\n\t\t\tgopts.Timeout = time.Duration(obj.Get(k).ToInteger()) * time.Millisecond\n\t\tcase \"waitUntil\":\n\t\t\tlifeCycle := obj.Get(k).String()\n\t\t\tif err := gopts.WaitUntil.UnmarshalText([]byte(lifeCycle)); err != nil {\n\t\t\t\treturn gopts, fmt.Errorf(\"parsing goto options: %w\", err)\n\t\t\t}\n\t\t}\n\t}\n\treturn gopts, nil\n}\n\n// parseFrameSetContentOptions parses the frame setContent options from a Sobek value.\nfunc parseFrameSetContentOptions(\n\trt *sobek.Runtime, opts sobek.Value, defaultTimeout time.Duration,\n) (*common.FrameSetContentOptions, error) {\n\tscopts := common.NewFrameSetContentOptions(defaultTimeout)\n\tif k6common.IsNullish(opts) {\n\t\treturn scopts, nil\n\t}\n\tobj := opts.ToObject(rt)\n\tfor _, k := range obj.Keys() {\n\t\tswitch k {\n\t\tcase \"timeout\":","sourceCodeStart":719,"sourceCodeEnd":755,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/frame_mapping.go#L719-L755","documentation":"parseFrameGotoOptions parses the `waitUntil` option of page.goto / frame.goto by calling Lifecycle.UnmarshalText on the provided string. When the string is not one of the recognized lifecycle events ('load', 'domcontentloaded', 'networkidle'), UnmarshalText returns an error which k6 wraps as 'parsing goto options'.","triggerScenarios":"Calling page.goto(url, { waitUntil: 'domContentLoaded' }) with wrong casing, or any misspelled/unsupported value such as 'commit', 'domcontentloaded ' (trailing space), 'network-idle', or a non-string like waitUntil: 2 (which is coerced to a string that fails parsing).","commonSituations":"Porting Playwright/Puppeteer scripts: Playwright supports 'commit' and 'domcontentloaded' but k6's browser module only supports load/domcontentloaded/networkidle; capitalization mistakes ('DOMContentLoaded'); copying docs from other tools that use different lifecycle names.","solutions":["Use one of the valid values: 'load', 'domcontentloaded', or 'networkidle' (all lowercase)","Fix casing — values are compared as plain text and are case-sensitive","Check the k6 browser module documentation for supported LifecycleEvent values for your k6 version","Remove waitUntil and rely on the default 'load'"],"exampleFix":"// before\nawait page.goto('https://example.com', { waitUntil: 'domContentLoaded' });\n\n// after\nawait page.goto('https://example.com', { waitUntil: 'domcontentloaded' });","handlingStrategy":"validation","validationCode":"const LIFECYCLE_EVENTS = ['load', 'domcontentloaded', 'networkidle'];\nfunction validGotoOptions(opts) {\n  return opts == null || opts.waitUntil === undefined || LIFECYCLE_EVENTS.includes(opts.waitUntil);\n}","typeGuard":"function isValidLifecycle(v) {\n  return ['load', 'domcontentloaded', 'networkidle'].includes(v);\n}","tryCatchPattern":"try {\n  await page.goto(url, { waitUntil: 'networkidle' });\n} catch (e) {\n  if (String(e).includes('parsing goto options')) {\n    throw new Error('waitUntil must be load|domcontentloaded|networkidle: ' + e);\n  }\n  throw e;\n}","preventionTips":["Use exact lowercase lifecycle names: load, domcontentloaded, networkidle","When porting from Playwright/Puppeteer, audit waitUntil values against k6's supported set","Do not pass numbers or objects for waitUntil","Centralize goto option construction in one helper that validates waitUntil"],"tags":["browser","goto","lifecycle-event","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-09-14T20:10:14.619Z","contentChangedAt":"2026-09-14T20:10:14.619Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}