volta icon indicating copy to clipboard operation
volta copied to clipboard

When using child_process.fork() with the execPath pointing to volta on windows ipc breaks.

Open Esurnir opened this issue 1 year ago • 1 comments

Linked Issue : vitest-dev/vscode#382

Windows version : 10 22H2 Reproduction repo : https://github.com/Esurnir/volta-vite-repro

Reproduction steps :

  1. Clone the repo,
  2. uncomment the line 11 of index.js
  3. open cmd
  4. 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.

Esurnir avatar May 16 '24 09:05 Esurnir

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

Esurnir avatar May 16 '24 10:05 Esurnir

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.

charlespierce avatar Aug 16 '24 17:08 charlespierce