deno
deno copied to clipboard
Deno task does not forward signal
// test.ts
Deno.addSignalListener("SIGTERM", () => {
console.log("term!");
Deno.exit();
});
setTimeout(() => {}, 30000);
// deno.json
{
"tasks": {
"sleep": "deno run -A test.ts",
}
}
Running deno run -A test.ts and kill -15 PID outputs:
term!
But deno task sleep and kill -15 PID (with the PID of the deno task runner, not the child deno process) outputs:
Task sleep deno run -A test.ts
fish: Job 1, 'deno task sleep' terminated by signal SIGTERM (Polite quit request)
The child process becomes a ghost, which is a pain to cleanup (e.g. an http server). I would expect deno task to behave like exec in bash or forward the signal to the child process.
All recent deno versions are affected.
Duplicate of https://github.com/denoland/deno_task_shell/issues/33?
Following
Just bumped into this as well. My Deno server process is unable to handle SIGTERM when run using deno task.
~~Can this be solved with execv?~~ No because of pipeline. I looked at the code, and, easiest way is to have a global variable acting as pub/sub for signals. Passing it around like Go's sync.Context also works. I got lost in the async .await call hierarchy. Where in the code is the new process spawned?
Workaround to kill -15 PID not working: kill -- -PID
Just hit this issue too. I'm trying to spawn a server inside my test files to run API tests but the server never closes.
Same here
I think this is still an issue at least with task processes spawned using Deno.ChildProcess. I created a new issue for that. https://github.com/denoland/deno/issues/29590
Bump. Still an issue.
Some context: I am working on a turbo mono-repo, with a Deno2 api app.
I launch with npm run dev, which runs turbo run dev, which for the deno api runs deno task dev.
when I close my IDE or that window, the deno process stays orphaned. I do not have this issue with other nodeJS processes. They shut down when I close their parent terminal/window.
I now have to have a killDeno npm script (pkill -f 'deno' ) that runs everytime I launch.
I wouldn't have to deal with stuff like this if I just trusted my gut and went with a Node api.
@iyobo please open a new issue with a reproduction (the steps you mentioned don't seem to use deno task). The issue originally reported no longer reproduces and so this specific issue will remain closed.
@dsherret It actually does use deno task. I had ellipsized it.
@iyobo the issue originally reported no longer reproduces. Please open a new issue with a full reproduction so that we can fix whatever that problem is. It might not be related to deno task not forwarding signals, but whatever calls deno task.