grafana/k6 · error
mouse move: %w
Error message
mouse move: %w
What it means
Root-level error from the internal Mouse.move(): an individual CDP Input.dispatchMouseEvent(mouseMoved) call failed during the interpolation loop. It is a raw Chrome DevTools Protocol failure: the session or target disappeared (page closed, browser crashed, websocket dropped), not a problem with the coordinates.
Source
Thrown at internal/js/modules/k6/browser/common/mouse.go:138
if err := m.move(x, y, opts); err != nil {
return fmt.Errorf("moving the mouse pointer to x:%f y:%f: %w", x, y, err)
}
return nil
}
func (m *Mouse) move(x float64, y float64, opts *MouseMoveOptions) error {
fromX := m.x
fromY := m.y
m.x = x
m.y = y
for i := int64(1); i <= opts.Steps; i++ {
x := fromX + (m.x-fromX)*float64(i/opts.Steps)
y := fromY + (m.y-fromY)*float64(i/opts.Steps)
action := input.DispatchMouseEvent(input.MouseMoved, x, y).
WithButton(m.button).
WithModifiers(input.Modifier(m.keyboard.modifiers))
if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
return fmt.Errorf("mouse move: %w", err)
}
}
return nil
}
View on GitHub (pinned to 93accf6570)
Solutions
- Check that Chromium is alive and not OOM-killed (container logs, dmesg)
- Guard the gesture: verify the page is open immediately before the move
- Restart the full gesture on a freshly created page; mouse position is lost with the session
- Reduce steps count to shrink the failure window
Example fix
// before
await page.mouse.move(800, 600, { steps: 40 });
// after
if (page.isClosed()) throw new Error('page closed before mouse.move');
await page.mouse.move(800, 600, { steps: 10 }); Defensive patterns
Strategy: try-catch
Validate before calling
if (page.isClosed()) throw new Error('page closed');
await page.mouse.move(x, y, { steps: 5 }); Try / catch
try {
await page.mouse.move(x, y, { steps: 5 });
} catch (e) {
// raw CDP mouseMoved failure == session/target loss
if (/target closed|connection/i.test(e.message)) {
throw new Error('browser session lost during mouse move');
}
throw e;
} Prevention
- Cap steps per move call
- Check browser process health in CI between scenarios
- Isolate gestures per page and drop state on failure
When it happens
Trigger: action.Do(cdp.WithExecutor(...)) for mouseMoved returning an error on any step: target destroyed, DevTools websocket closed, browser process crash or OOM kill mid-gesture.
Common situations: Chromium killed under memory pressure during long drag simulations; page closed while a multi-step move was in flight; flaky remote CDP connection; continuing after an earlier unhandled error left the session dead.
Related errors
- mouse down: %w
- mouse up: %w
- evaluating pointer action: %w
- run if waiting for debugger to attach: %w
- internal error while enabling %T: %w
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/d93b4fb59dbc5556.
Report an issue: GitHub.