Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vitest will crash when using ffi-napi #2091

Closed
5 of 6 tasks
LizardLiang opened this issue Sep 28, 2022 · 5 comments
Closed
5 of 6 tasks

vitest will crash when using ffi-napi #2091

LizardLiang opened this issue Sep 28, 2022 · 5 comments
Labels

Comments

@LizardLiang
Copy link

LizardLiang commented Sep 28, 2022

Describe the bug

when using ffi-napi module, vitest cannot fully finish its job
image

after i remove file include ffi-napi, it becomes normal again
image

Reproduction

In any testing file add
const ffi = require('ffi-napi')

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
    Memory: 16.55 GB / 31.80 GB
  Binaries:
    Node: 16.17.0 - ~\scoop\apps\nvm\current\nodejs\nodejs\node.EXE
    npm: 8.15.0 - ~\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (105.0.1343.50)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @vitejs/plugin-react: ^2.1.0 => 2.1.0
    vite: ^3.1.0 => 3.1.3
    vitest: ^0.23.4 => 0.23.4

Used Package Manager

npm

Validations

@sheremet-va
Copy link
Member

According to node-ffi-napi/node-ffi-napi#125 you cannot use it inside a worker thread. Vitest runs tests only inside worker threads.

@marcoroth
Copy link

Is there any workaround for this? Or do I have to ditch vitest when testing modules using ffi-napi? 🥲

@AriPerkkio
Copy link
Member

Is there any workaround for this?

Use --no-threads. Or if you are using v1-beta releases, use --pool=forks.

@AriPerkkio
Copy link
Member

Fixed by #3925 and #4172.

Vitest 1.0.0-beta has now --pool=forks which uses multiple node:child_process in parallel. The previous --no-threads was using a single node:child_process.

If the code you are testing is incompatible with node:worker_threads, switch to --pool=forks. If you run into same error with that pool, feel free to open new issue with minimal reproduction.

@marcoroth
Copy link

Awesome, thanks @AriPerkkio! Using --pool=forks works perfectly!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants