grafana/k6 · error
parsing frame dispatch event options
Error message
parsing frame dispatch event options: %w
What it means
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.
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
Example fix
// before
await frame.dispatchEvent('#el', 'click', { timeout: 5000 });
// after
await frame.dispatchEvent('#el', 'click', null, { timeout: 5000 }); Defensive patterns
Strategy: try-catch
Validate before calling
if (opts != null && typeof opts !== 'object') {
throw new Error(`dispatchEvent options must be an object, got ${typeof opts}`);
}
await frame.dispatchEvent(selector, type, eventInit, opts); Try / catch
try {
await frame.dispatchEvent(sel, type, eventInit, opts);
} catch (e) {
if (String(e).includes('parsing frame dispatch event options')) {
await frame.dispatchEvent(sel, type, eventInit); // retry with defaults
} else { throw e; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- parse isEditable options of selector
- parse isEnabled options of selector
- parse isHidden options of selector
- parse isVisible options of selector
- parse press options of selector
AI-assisted analysis of grafana/k6@8d06114777 (2026-09-14).
Data as JSON: /api/errors/56e54032ca79f618.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/frame_mapping.go:65
},
"content": func() *sobek.Promise {
return promise(vu, func() (any, error) {
return f.Content() //nolint:wrapcheck
})
},
"dblclick": func(selector string, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseFrameDblclickOptions(rt, opts, f.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing double click options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, f.Dblclick(selector, popts) //nolint:wrapcheck
}), nil
},
"dispatchEvent": func(selector, typ string, eventInit, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseFrameDispatchEventOptions(rt, opts, f.Timeout())
if err != nil {
return nil, fmt.Errorf("parsing frame dispatch event options: %w", err)
}
earg := exportArg(eventInit)
return promise(vu, func() (any, error) {
return nil, f.DispatchEvent(selector, typ, earg, popts) //nolint:wrapcheck
}), nil
},
"evaluate": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
if sobekEmptyString(pageFunc) {
return nil, fmt.Errorf("evaluate requires a page function")
}
funcString := pageFunc.String()
gopts := exportArgs(gargs)
return promise(vu, func() (any, error) {
return f.Evaluate(funcString, gopts...)
}), nil
},
"evaluateHandle": func(pageFunc sobek.Value, gargs ...sobek.Value) (*sobek.Promise, error) {
if sobekEmptyString(pageFunc) {View on GitHub (pinned to 8d06114777)