vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
728 stars 79 forks source link

Volta support / Process exited with code 0 #382

Closed Esurnir closed 2 months ago

Esurnir commented 2 months ago

Describe the bug

When running visual studio code on a system using volta (With lts installed as the default node version). The visual studio code extension fail to start.

It seems to open the node process with the "C:\Program Files\Volta\node.EXE" --dns-result-order=ipv4first C:/Users/jbzeller/.vscode/extensions/vitest.explorer-0.10.2/dist/worker.js command line. which seems to open then close immediately without error. The command is then relayed to the real node installation.

Reproduction

  1. Use https://github.com/vitest-dev/vitest/tree/main/examples/basic as a basic sample folder.
  2. Install volta on your machine (uninstalling existing node installation first).
  3. volta install node@20
  4. In the folder run npm install
  5. Open visual studio code with the vitest extension installed.

Output

[INFO 16:14:41] [v0.10.2] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 16:14:42] [API] Running Vitest: v1.6.0 (vite.config.ts)
[INFO 16:14:42] [API] Starting Vitest process with Node.js: C:\Program Files\Volta\node.EXE
[Error 16:14:43] [Error Error] Vitest process exited with code 0
Error: Vitest process exited with code 0
    at ChildProcess.d (c:\Users\jbzeller\.vscode\extensions\vitest.explorer-0.10.2\dist\extension.js:21:170)
    at ChildProcess.emit (node:events:517:28)

Version

0.10.2

Validations

mil7 commented 2 months ago

This bug report is totally related to this discussion: https://github.com/vitest-dev/vscode/discussions/378 . With a great addition: A correlation with volta is made.

Esurnir commented 2 months ago

I got some news !

This is due to the fact the extension is using the execPath option to point to volta instead of not using the option.

Repro here sorry in advance I was trying different things in that repo to reproduce the issue.

How to reproduce (sorry I put the working test case in the repo, to get the failing case, uncomment execPath): Without execPath everything works great.

  1. Clone.
  2. Go to the folder.
  3. execute "C:\Program Files\Volta\node.EXE" index.js You get ipc working, the process keeps working. output
    
    D:\Git\Labo\voltaprocess>"C:\Program Files\Volta\node.EXE" index.js
    stdout: Dad is here

PARENT got message: Hello dad ! stdout: path: D:\Git\Labo\voltaprocess

stdout: CHILD got message: parent -> child

^C^C


Now uncomment execPath, the process exit and the parent doesn't get any output on the message event, everything broken.
Output :
```cmd
D:\Git\Labo\voltaprocess>"C:\Program Files\Volta\node.EXE" index.js
stdout: Dad is here

stdout: path:  D:\Git\Labo\voltaprocess

Child exited output Dad is here
path:  D:\Git\Labo\voltaprocess

D:\Git\Labo\voltaprocess>
sheremet-va commented 2 months ago

We need to point to user's Node.js, not VSCode's instance. This doesn't fix the issue, but creates another.

Esurnir commented 2 months ago

Created an issue on volta about the issue.

The command "volta which node" output the executable that'll be run in the current folder (if we decide to add a volta workaround and volta just can't relay the ipc messages).

D:\Git\Labo\voltaprocess>volta which node
C:\Users\jbzeller\AppData\Local\Volta\tools\image\node\20.13.1\node.exe

D:\Git\Labo\voltaprocess>
sheremet-va commented 2 months ago

The command "volta which node" output the executable that'll be run in the current folder (if we decide to add a volta workaround and volta just can't relay the ipc messages).

PR welcome to add support for this, shouldn't be hard to do