Skip to content

Browser-Mode fails in insecure environmentΒ #9338

@plusgut

Description

@plusgut

Describe the bug

When using vitest with a server configured to not use localhost, but any other domain without https, vitest fails with the exception "TypeError: crypto.randomUUID is not a function" thrown in wrapModule

const moduleId = crypto.randomUUID()

The function crypto.randomUUID is not available in insecure environments https://developer.mozilla.org/de/docs/Web/API/Crypto/randomUUID
In CI setups with a remote-selenium-hub it is very useful to spin up vitest-server accessable through the machines hostname, without the need to configure tls.

I consider this a regression, since a similar thing got fixed in #6079

Reproduction

plusgut/vitest-minimal-reproduction-randomuui@02a2398

System Info

System:
    OS: Linux 6.18 cpe:/o:nixos:nixos:26.05 26.05 (Yarara)
    CPU: (16) x64 AMD Ryzen 7 PRO 5850U with Radeon Graphics
    Memory: 17.72 GB / 27.23 GB
    Container: Yes
    Shell: 4.2.1 - /run/current-system/sw/bin/fish
  Binaries:
    Node: 22.21.1 - /nix/store/l85fis49agvp5q1ild1rfh4rrgmn92sr-nodejs-22.21.1/bin/node
    npm: 10.9.4 - /nix/store/l85fis49agvp5q1ild1rfh4rrgmn92sr-nodejs-22.21.1/bin/npm
  Browsers:
    Chromium: 143.0.7499.40
    Firefox: 145.0.2
    Firefox Developer Edition: 145.0.2
  npmPackages:
    @vitest/browser-preview: ^4.0.16 => 4.0.16 
    @vitest/ui: latest => 4.0.16 
    vite: latest => 7.3.0 
    vitest: latest => 4.0.16

Used Package Manager

npm

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions