Comments (8)
Any chance of taking a second look at this issue?
I just ran into this in a CI script running a node server for testing. As a simple repro:
test-server.js
const server = require('http').createServer((_, response) => {
response.end('hello there\n');
});
server.listen(10200);
test.sh
#!/bin/sh
node test-server.js &
sleep 5
curl http://localhost:10200
sleep 5
kill $!
curl http://localhost:10200
When using volta, the second curl
call doesn't fail as it should, and a zombie node process spawned by http.Server
is left running. Without volta the script runs as expected and there's no zombie process.
#36 (comment) brings up good points about expectations (and ctrl-c
mid-run does indeed properly kill the server process in this case, which is nice), but it seems like node is doing the right thing with signal handling in the non-volta case, and if you're a happy volta user but don't know much about volta shims (as I didn't until today :), it's not entirely clear how to know you need to handle this case, or, once you do, the best way to handle it.
from volta.
@brendankenny Thanks for raising this up again! I think that the scripted use-case is an important point, since it's a spot where you can't (reasonably) send a Ctrl+C to the process to kill it, you instead need to be able to pass a signal.
from volta.
That said, I don't know if passing signals along is actually what we want to do, as the child process is a separate process, with a separate PID, from the parent. So it seems reasonable that a user would expect the processes to be mostly independent as far as direct signals are concerned.
I would argue the opposite here. Volta shims should, arguably, be as transparent to the end user as possible. A user of Volta shouldn't need to work with the node process any differently than if they'd installed it natively. That in my mind was one of the nice selling points of Volta as a tool from the get-go in terms of how it holds node/npm/global versions of all your dependencies and seamlessly switches between them. Fudging with child processes to properly kill running processes seems to be the antithesis of how Volta sells itself. I realize actually implementing this might not be trivial. But it seems like an important piece to get right.
from volta.
Some important links:
- unix:
- windows:
from volta.
I did some investigation of this today. We don't currently propagate signals, however, what we do do is forward the STDIN to the child process. So if the user kills the process using a keyboard shortcut (like Ctrl + C
to send SIGINT
), that will be sent to the child process, and in fact will only go to the child process, instead of being interpreted by Volta.
However, if we send the SIGINT
signal directly using e.g. kill -2
, then it will interrupt the Volta process without affecting the child process, leading to some weird indeterminate behavior.
That said, I don't know if passing signals along is actually what we want to do, as the child process is a separate process, with a separate PID, from the parent. So it seems reasonable that a user would expect the processes to be mostly independent as far as direct signals are concerned.
Lastly, while the main shim child processes do forward along the STDIN, I'm not sure that all of our child processes do. So we should, at the very least, do some auditing to make sure that all of our child processes use .stdin(Stdio::inherit)
. This will make sure that when we pause waiting for a child process, we allow the Ctrl + C
keyboard shortcut to propagate to the child process and allow those to be shut down gracefully as well.
from volta.
I'm working on an Electron App, which spawns child node processes (using the host machines' installed nodejs), and I need to terminate these processes with signals. When using Volta, childProcess.kill()
won't terminate the child process, just the Volta Shim. Though process.kill(-childProcess.pid);
does a good job on OSX and Linux as it kills the process group, but doesn't work on Windows.
Is there any chance this gets fixed anytime soon?
from volta.
@vanstinator That's a good point and well stated, thanks! There's a lot of platform-specific nuance with signal handling (since Windows doesn't have signals in the same way as MacOS / Linux), but I agree that getting it right will make Volta more appropriately transparent, especially for these "launch as a sub-process" use-cases.
from volta.
Any progress on this? I'm developing a process manager that works with Volta, and I want to shutdown a given node process.
from volta.
Related Issues (20)
- Potential fork bomb
- how to solve pnpm's problem HOT 3
- When trying to install new versions volta hangs indefinitely and blocks all other network requests from resolving HOT 39
- Unable to install nativescript (CLI) HOT 2
- When using child_process.fork() with the execPath pointing to volta on windows ipc breaks. HOT 1
- Volta changed the toolchain action HOT 1
- mkgainet.
- uninstall failed HOT 2
- Can I use it on a prodcution server with pm2? HOT 1
- [PSA] yarn version discrepancy
- 1.1.2 HOT 6
- how to use it in Jenkins or gitlab ci? HOT 2
- error: Could not unpack Node v20.15.0 HOT 5
- Node & package versions HOT 1
- <removed>
- Suggestion to Introduce volta use as an Alias for volta pin HOT 1
- Newlines in arguments passed to `node -e ...` HOT 4
- Provide ways for airgapped node/npm/yarn install HOT 3
- Issue with pnpm 9 Installed via Volta: Dependencies Not Installed Properly in Monorepo HOT 2
- Node current version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from volta.