When using child_process.fork() with the execPath pointing to volta on windows ipc breaks.
Linked Issue : vitest-dev/vscode#382
Windows version : 10 22H2 Reproduction repo : https://github.com/Esurnir/volta-vite-repro
Reproduction steps :
- Clone the repo,
- uncomment the line 11 of index.js
- open cmd
- run in cmd "C:\Program Files\Volta\node.EXE" index.js Expected 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
process does not close by itself.
actual output :
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>
process closed.
This cause the issue of the vscode vitest plugin not working.
I just realized I switched the output. The first output is the passing output. The second one is the failing. I'll edit it when I get home. Edit : nevermind I just read it too quickly, expected -> actual
Hi @Esurnir, thanks for reaching out! I believe this is a duplicate of #1032 and is unfortunately a result of how Volta works—since it's implemented with shims, the node.exe is not itself directly a Node executable, so the IPC breaks (in that other issue I quote from the docs talking about how IPC only works when it's direct node -> node spawning.
Depending on the use-case, one workaround would be to use volta which node to resolve the path to the Node executable directly, and then spawn that with IPC, which should work because it's calling Node directly.