grafana/k6 · error
parsing mouse double click options
Error message
parsing mouse double click options: %w
What it means
Thrown by mouse.dblClick(x, y, options) when parseMouseDblClickOptions fails. The double-click parser (browser/mouse_mapping.go:101-118) accepts only 'button' (string) and 'delay' (integer); a non-integer delay or a non-object options value is wrapped with this message before any input event is dispatched.
Solutions
- Pass an integer delay: { delay: 100 } or omit it for zero delay.
- Coerce and round: { delay: Math.round(Number(cfg.delay)) } with an is-integer check.
- Keep 'button' a string among 'left' | 'right' | 'middle'.
- Do not reuse mouse.click option objects verbatim if their delay is not an integer.
Example fix
// before
await page.mouse().dblClick(10, 20, { delay: cfg.pauseMs }); // "120"
// after
await page.mouse().dblClick(10, 20, { delay: Number(cfg.pauseMs) | 0 }); Defensive patterns
Strategy: validation
Validate before calling
const opts = cfg.delay == null ? {} : { delay: Math.round(Number(cfg.delay)) };
if (opts.delay != null && !Number.isInteger(opts.delay)) throw new Error('delay must be an integer');
await page.mouse().dblClick(x, y, opts); Type guard
function isDblClickOptions(o) {
if (o == null) return true;
if (typeof o !== 'object') return false;
return (o.delay == null || Number.isInteger(o.delay)) && (o.button == null || typeof o.button === 'string');
} Try / catch
try { await page.mouse().dblClick(x, y, opts); } catch (e) { if (/parsing mouse double click options|delay must be an integer/.test(e.message)) { await page.mouse().dblClick(x, y, { ...opts, delay: Math.round(Number(opts.delay)) }); } else throw e; } Prevention
- Keep dblClick options to { button?: string; delay?: integer }.
- Never pass a string delay from env/config without Number() conversion.
- Round fractional pacing delays before use.
When it happens
Trigger: page.mouse().dblClick(10, 20, { delay: '100' }), { delay: 100.5 }, or a non-object third argument. Passing 'clickCount' is silently ignored here (double click fixes the count), so delay type errors dominate.
Common situations: Delay injected from environment/config as a string (COMMA separated env parsing); float delays from pacing calculations; copy-paste between click and dblClick option objects that carried a string delay.
Related errors
- parsing mouse click options
- parsing mouse down options
- parsing mouse move options
- parsing mouse up options
- clickCount must be an integer, got
AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18).
Data as JSON: /api/errors/92685cb364a18bc8.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/browser/mouse_mapping.go:28
k6common "go.k6.io/k6/v2/js/common"
)
func mapMouse(vu moduleVU, m *common.Mouse) mapping {
rt := vu.Runtime()
return mapping{
"click": func(x float64, y float64, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseMouseClickOptions(rt, opts)
if err != nil {
return nil, fmt.Errorf("parsing mouse click options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, m.Click(x, y, popts) //nolint:wrapcheck
}), nil
},
"dblClick": func(x float64, y float64, opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseMouseDblClickOptions(rt, opts)
if err != nil {
return nil, fmt.Errorf("parsing mouse double click options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, m.DblClick(x, y, popts) //nolint:wrapcheck
}), nil
},
"down": func(opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseMouseDownUpOptions(rt, opts)
if err != nil {
return nil, fmt.Errorf("parsing mouse down options: %w", err)
}
return promise(vu, func() (any, error) {
return nil, m.Down(popts) //nolint:wrapcheck
}), nil
},
"up": func(opts sobek.Value) (*sobek.Promise, error) {
popts, err := parseMouseDownUpOptions(rt, opts)
if err != nil {
return nil, fmt.Errorf("parsing mouse up options: %w", err)View on GitHub (pinned to 01ffac6f24)