Skip to content

Failed to execute 'addEventListener' on 'EventTarget' when passing a signal from AbortController to addEventListener - vitest@"^4.0.0-beta.10" #8563

@prscoelho

Description

@prscoelho

Describe the bug

On the latest beta version, "vitest": "^4.0.0-beta.10", when passing a signal from new AbortController() to addEventListener, vitest fails with the following error:

function App() {
  useEffect(() => {
    const abortController = new AbortController();
    const options = {
      signal: abortController.signal,
    };
    document.addEventListener("pointerdown", () => {}, options);
  }, []);

  return <div>Hello world</div>;
}
Failed to execute 'addEventListener' on 'EventTarget': parameter 3 dictionary has member 'signal' that is not of type 'AbortSignal'.

Downgrading back to 3.2.4 fixes the issue. Maybe related to #8390

Reproduction

Link to repro - run npm run test, it should fail
https://stackblitz.com/edit/vitejs-vite-gcbbdqsx?file=src%2FApp.spec.tsx

Downgrading vitest back to latest fixes the problem

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
    Memory: 6.58 GB / 31.73 GB
  Binaries:
    Node: 24.7.0 - ~\scoop\apps\nvm\current\nodejs\nodejs\node.EXE
    npm: 11.5.1 - ~\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (140.0.3485.54)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @vitejs/plugin-react: ^5.0.0 => 5.0.2
    vite: ^7.1.2 => 7.1.5
    vitest: ^4.0.0-beta.10 => 4.0.0-beta.11

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p4-importantViolate documented behavior or significantly improves performance (priority)

    Type

    Projects

    Status

    High Priority

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions