{"record":{"id":"56e54032ca79f618","repo":"grafana/k6","slug":"parsing-frame-dispatch-event-options-w","errorCode":null,"errorMessage":"parsing frame dispatch event options: %w","messagePattern":"parsing frame dispatch event options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/browser/browser/frame_mapping.go","lineNumber":65,"sourceCode":"\t\t},\n\t\t\"content\": func() *sobek.Promise {\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn f.Content() //nolint:wrapcheck\n\t\t\t})\n\t\t},\n\t\t\"dblclick\": func(selector string, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseFrameDblclickOptions(rt, opts, f.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing double click options: %w\", err)\n\t\t\t}\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, f.Dblclick(selector, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"dispatchEvent\": func(selector, typ string, eventInit, opts sobek.Value) (*sobek.Promise, error) {\n\t\t\tpopts, err := parseFrameDispatchEventOptions(rt, opts, f.Timeout())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"parsing frame dispatch event options: %w\", err)\n\t\t\t}\n\t\t\tearg := exportArg(eventInit)\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn nil, f.DispatchEvent(selector, typ, earg, popts) //nolint:wrapcheck\n\t\t\t}), nil\n\t\t},\n\t\t\"evaluate\": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {\n\t\t\tif sobekEmptyString(pageFunc) {\n\t\t\t\treturn nil, fmt.Errorf(\"evaluate requires a page function\")\n\t\t\t}\n\t\t\tfuncString := pageFunc.String()\n\t\t\tgopts := exportArgs(gargs)\n\t\t\treturn promise(vu, func() (any, error) {\n\t\t\t\treturn f.Evaluate(funcString, gopts...)\n\t\t\t}), nil\n\t\t},\n\t\t\"evaluateHandle\": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {\n\t\t\tif sobekEmptyString(pageFunc) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/js/modules/k6/browser/browser/frame_mapping.go#L47-L83","documentation":"Thrown when Frame.dispatchEvent cannot parse its options. FrameDispatchEventOptions embeds only FrameBaseOptions, whose Parse coerces strict (ToBoolean) and timeout (ToInteger) and ignores unknown keys — there is no realistic error path, so this wrap is defensive. Argument-order mistakes do not produce this error because eventInit and opts are separate parameters.","triggerScenarios":"Calling frame.dispatchEvent(selector, type, eventInit, opts) with an opts value that cannot become an object (e.g. a Symbol). Ordinary objects, numbers, null and undefined all pass.","commonSituations":"Practically unseen; passing eventInit in the opts slot (swapped 3rd/4th args) silently mis-parses but does not error — a subtle correctness bug rather than this message.","solutions":["Keep the argument order: (selector, type, eventInit, options) with options a plain object like {timeout: 5000}","If seen, read the wrapped error text after the colon for the true runtime cause","Reproduce with stock k6 and file an issue if it persists"],"exampleFix":"// before\nawait frame.dispatchEvent('#el', 'click', { timeout: 5000 });\n// after\nawait frame.dispatchEvent('#el', 'click', null, { timeout: 5000 });","handlingStrategy":"try-catch","validationCode":"if (opts != null && typeof opts !== 'object') {\n  throw new Error(`dispatchEvent options must be an object, got ${typeof opts}`);\n}\nawait frame.dispatchEvent(selector, type, eventInit, opts);","typeGuard":null,"tryCatchPattern":"try {\n  await frame.dispatchEvent(sel, type, eventInit, opts);\n} catch (e) {\n  if (String(e).includes('parsing frame dispatch event options')) {\n    await frame.dispatchEvent(sel, type, eventInit); // retry with defaults\n  } else { throw e; }\n}","preventionTips":["Keep the 4-argument order (selector, type, eventInit, options) explicit — never swap slots 3 and 4","Pass eventInit as null when there is no init payload","Treat this parse message as an internal error; real mistakes surface as wrong-event behaviour, not this wrap"],"tags":["k6","browser","frame","dispatchevent","options"],"backgroundTag":"options-validation-failed","analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-09-14T20:10:14.619Z","contentChangedAt":"2026-09-14T20:10:14.619Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}