Skip to content

Inexplicable and flaky userEvent action timeouts #7871

@nstepien

Description

@nstepien

Describe the bug

Since the version 3.1.2, some tests became flaky: userEvent (from @vitest/browser/context) actions lead to unexpected timeout errors.
These tests used to work in 3.1.1, the call logs do not reveal any issues, the screenshots look good, the actions should work, it's really inexplicable why these timeout errors start happening.
I cannot reproduce these errors at all locally, it's only happening in our CI, no clue why.

Here's a couple examples below:

TimeoutError: locator.hover: Timeout 581ms exceeded.
Call log:
  - waiting for locator('[data-vitest="true"]').contentFrame().locator('body')
    - locator resolved to <body>…</body>
  - attempting hover action
    - waiting for element to be visible and stable
    - element is visible and stable
    - scrolling into view if needed
    - done scrolling

It says "Timeout 581ms exceeded", but it's not like we set an explicit 581ms timeout limit, really odd.

TimeoutError: frame.dragAndDrop: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('div:nth-child(4) > .dragIconClassname_d1f2l6jt')

Here setting a 10s timeout limit, and it's still exceeded, even though it should pass/not timeout.

TimeoutError: locator.hover: Timeout 5000ms exceeded.
Call log:
  - waiting for locator('[data-vitest="true"]').contentFrame().locator('body')
    - locator resolved to <body>↵  ↵↵</body>
  - attempting hover action
    - waiting for element to be visible and stable
    - element is visible and stable
    - scrolling into view if needed
    - done scrolling
TimeoutError: locator.hover: Timeout 5000ms exceeded.
Call log:
  - waiting for locator('[data-vitest="true"]').contentFrame().locator('body')
    - locator resolved to <body>…</body>
  - attempting hover action
    - waiting for element to be visible and stable

Reproduction

A simple

await userEvent.hover(document.body, { position: { x: 0, y: 0 } });

can timeout in our CI since 3.1.2.

This is with the playwright provider.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (32) x64 AMD Ryzen 9 9950X3D 16-Core Processor
    Memory: 36.50 GB / 63.58 GB
  Binaries:
    Node: 23.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.3.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (131.0.2903.99)
  npmPackages:
    @vitejs/plugin-react: ^4.4.1 => 4.4.1
    @vitest/browser: ^3.1.2 => 3.1.2
    @vitest/coverage-v8: ^3.1.2 => 3.1.2
    playwright: ~1.52.0 => 1.52.0
    vite: ^6.3.2 => 6.3.2
    vitest: ^3.1.2 => 3.1.2
    vitest-browser-react: ^0.1.1 => 0.1.1

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions