puter icon indicating copy to clipboard operation
puter copied to clipboard

`npm start` leaves webpack processes lying around

Open AtkinsSJ opened this issue 10 months ago • 3 comments

Noticed this initially when I started getting a whole bunch of errors like this when running npm start:

[INFO::__dev-watcher] (3.967s) [puter.js:webpack-watch:err] Watchpack Error (watcher): Error: EMFILE: too many open files, watch '/home/sam/Projects/HeyPuter/puter/packages/puter-js'

I'd been repeatedly starting puter, then stopping it with Ctrl-C, to test some changes I was making.

Sure enough, looking at the process monitor, I had a lot of webpack processes still around from previous npm starts. It seems that however they are spawned, they don't die with the parent process.

AtkinsSJ avatar Apr 25 '24 17:04 AtkinsSJ

The EMFILE error might have been caused by some of my local changes, but the webpack issue isn't.

AtkinsSJ avatar Apr 25 '24 17:04 AtkinsSJ

I was worried this might happen. I actually have no idea how to make sure child processes actually exit in node - maybe it can't be done? Maybe we need to record PIDs and invoke the kill command on the exit handler? I'm adding the "help wanted" label to this.

KernelDeimos avatar Apr 26 '24 00:04 KernelDeimos

It looks like this might be specific to UNIX with using spawn and shell:true.

Adding detached: true in spawn and using process.kill(-proc.pid) seems to work, but I'm not entirely sure if this alters some behavior that we don't want.

Here's something related I found. Issue #46865 in Node.

Eric-Lighthall avatar Apr 26 '24 06:04 Eric-Lighthall