-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Problem
deno run --watch
does not exit when receiving SIGINT if the code has registered a SIGINT handler.
Minimal Reproducible Example
test.ts
:
const ac = new AbortController();
Deno.addSignalListener("SIGINT", () => {
console.log("SIGINT");
ac.abort();
});
Deno.serve({ signal: ac.signal }, () => new Response("Hello World"));
Run deno run -A test.ts
and press CTRL+C to send a SIGINT. Deno will print SIGINT to the console, indicating the code has received the SIGINT, and exit. The output looks like this:
Listening on http://0.0.0.0:8000/ (http://localhost:8000/)
^CSIGINT
Now run deno run --watch -A test.ts
and press CTRL+C to send a SIGINT. Deno will print SIGINT to the console, once again indicating the code has received the SIGINT, but will not exit. It does report that the watcher process has exited however. The output looks like this:
Watcher Process started.
Listening on http://0.0.0.0:8000/ (http://localhost:8000/)
^CSIGINT
Watcher Process finished. Restarting on file change...
^C^C^C^C^C
Repeatedly pressing CTRL+C after the watcher process has exited has no effect, as can be seen by the last line of output.
Version
deno 2.4.5 (stable, release, x86_64-unknown-linux-gnu)
v8 13.7.152.14-rusty
typescript 5.8.3
Previous Issues
It seems this has been a problem before, this issue (now closed) reports what I assume is the same problem: #18676.
It was resolved by this PR: #18678.