Skip to content

[Bug]: Vitest breaks with @rolldown/binding-wasm32-wasi #8740

@AriPerkkio

Description

@AriPerkkio

Reproduction link or steps

Reproduction narrowed down to @rolldown/binding-wasm32-wasi by @SamVerschueren. 🤝

  1. Open https://vitest.new and download the template locally.
  2. Add "@rolldown/binding-wasm32-wasi": "latest" to dependencies
  3. npm install --force
  4. Run npm test while overriding binary: NAPI_RS_NATIVE_LIBRARY_PATH=@rolldown/binding-wasm32-wasi npm test

For full stacktrace, search stackIgnorePatterns in node_modules and empty those 2x arrays.

Error: Cannot read properties of undefined (reading 'whenLoaded')
 ❯ reviveInvokeError node_modules/vite/dist/node/module-runner.js:538:14
 ❯ Object.invoke node_modules/vite/dist/node/module-runner.js:554:33
 ❯ processTicksAndRejections node:internal/process/task_queues:105:5
 ❯ VitestModuleRunner.getModuleInformation node_modules/vite/dist/node/module-runner.js:1183:7
 ❯ VitestModuleRunner.import node_modules/vite/dist/node/module-runner.js:1099:23
 ❯ node_modules/@vitest/runner/dist/index.js:1811:5
 ❯ collectTests node_modules/@vitest/runner/dist/index.js:1788:3
 ❯ startTests node_modules/@vitest/runner/dist/index.js:2631:17
 ❯ node_modules/vitest/dist/chunks/base.DM0-RqVb.js:90:5
 ❯ run node_modules/vitest/dist/chunks/base.DM0-RqVb.js:81:2

There is no whenLoaded defined in Vitest sources.

What is expected?

It should work without errors.

What is actually happening?

$ NAPI_RS_NATIVE_LIBRARY_PATH=@rolldown/binding-wasm32-wasi npm test

> test
> vitest

(node:37751) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:37751) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:37751) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

 DEV  v4.1.0 /x/vitest-dev-vitest-vc8maafp

 ❯ test/suite.test.ts (0 test)
 ❯ test/basic.test.ts (0 test)

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Suites 2 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/basic.test.ts [ test/basic.test.ts ]
 FAIL  test/suite.test.ts [ test/suite.test.ts ]
Error: Cannot read properties of undefined (reading 'whenLoaded')
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯


 Test Files  2 failed (2)
      Tests  no tests
   Start at  21:28:06
   Duration  103ms (transform 0ms, setup 0ms, import 0ms, tests 0ms, environment 0ms)

 FAIL  Tests failed. Watching for file changes...
       press h to show help, press q to quit

System Info

System:
    OS: macOS 26.3.1
    CPU: (8) arm64 Apple M2
    Memory: 1.58 GB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 22.22.0 - /x/.nvm/versions/node/v22.22.0/bin/node
    Yarn: 1.22.22 - /x/.nvm/versions/node/v22.22.0/bin/yarn
    npm: 10.9.4 - /x/.nvm/versions/node/v22.22.0/bin/npm
    pnpm: 10.31.0 - /x/.nvm/versions/node/v22.22.0/bin/pnpm
    bun: 1.3.9 - /x/.bun/bin/bun
  Browsers:
    Safari: 26.3.1

Any additional comments?

This breaks https://vitest.new that's using wasm build of rolldown.

Metadata

Metadata

Assignees

No one assigned

    Type

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions