denon: denon [script name] doesn't kill app on reload
I have a simple web server application running with oak. When I use the command denon run --allow-net app.ts
the auto reload successfully kill the webserver on each reload.
But when I use the denon dev
command and using the denon.json file, the application isn’t killed on each reload. For example, if I run the webserver on 8080 port, then change it to 8081 then save, I end up with 2 webserver. If I doesn’t change the port between two save, I hand up with an error saying one app already use this port.
Here is my denon.json file
And my app.ts file
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 4
- Comments: 36 (6 by maintainers)
I have also confirmed this to still be a problem, using Windows 10, Deno 1.6.3, and Denon 2.4.5. I believe the problem is that when the killAll() routine in deamon.ts calls p.close() under Windows, this is not actually killing the process. Can confirm this with ProcessExplorer, and see that the original process ID is never killed, and subsequent processes die due to the Socket reuse error.
I’m not a Github guru, so I’m just posting my small change here, adding p.kill() to the Windows case, which fixes the problem for me.
Could also just get rid of the whole “if” and use kill() always. But I’m sure p.close() was added specially for Windows for some reason, and based on other reports here it seems to sometimes work, so I’m not sure why it is not working for all of us. I’m also not sure whether kill() has any bad/unintended effects in Windows.
Thanks @dale-roberts , I submitted a pull request for your suggestion: #120
I have recreated your environment in a windows vm but I can’t reproduce the issue. If you have time come to our discord server so we can have a faster way of communication.
@meganyin13
Hi, I tested the project you linked in this issue with my Mac, adding:
to the denon.json file. It seems to be working without any problems.
"start": "deno run --allow-net --allow-read server/staticServer.ts"
"start": "denon run --allow-net --allow-read server/staticServer.ts"
As you can see you are making denon run a
denon
command which spawns two daemons instead of adeno
command.I am also having this issue on macOS Catalina using denon
v2.0.0
and deno1.0.2
with my start script:"start": "denon run --allow-net --allow-read server/staticServer.ts"
Interesting because just usingdenon run
command on its own works fine. However,denon [script]
doesn’t close the app properly on reload. Also seems that when we get this error the whole app crashes 😕