-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
denon [script name] doesn't kill app on reload #49
Comments
In what os are you experiencing this issue? |
Windows 10 Pro 64 bits |
I can't seem to reproduce this issue on windows. Are you using the latest version of deno? ( |
I'm using deno 1.0.2 and denon 2.0.0. Here is the error log I got when I have two process running on the same port. The error is in French because my operating system is in French. It say "Only one usage of every socket port is authorised". |
If you close down deno in the task manager and try again do you still get the error? I can't seem to reproduce it. What does your path look like? |
Done it, nothing changed. |
I am also having this issue on macOS Catalina using denon |
Hi, I tested the project you linked in this issue with my Mac, adding: "scripts": {
"start": "deno run --allow-net --allow-read server/staticServer.ts"
}, to the denon.json file. It seems to be working without any problems.
As you can see you are making denon run a |
@Trystan-SA {
"logger": {
"debug": true
}
} If the problem reoccurs please write a message here with all the stdout from denon. Thanks 🌟 |
With commit 2143585 I removed the faulty error message log. Can you please |
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. |
Local execution process.close() or self.close() are working well. |
The current debug logs for this issue:
|
Most likely related to deno#7824 |
error: Uncaught AddrInUse: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)
at unwrapResponse (rt/10_dispatch_json.js:24:13)
at sendSync (rt/10_dispatch_json.js:51:12)
at opListen (rt/30_net.js:33:12)
at Object.listen (rt/30_net.js:204:17)
at Object.listen (rt/40_net_unstable.js:11:18)
at Application.serve (server.ts:287:25)
at Application.listen (application.ts:363:20)
at Server.run (file:///B:/projek-deno/denovel/vendor/Denovel/mod.ts:15:1)
at file:///B:/projek-deno/denovel/server.ts:3:1
at <anonymous> (<anonymous>)
[E] [daem] app crashed - waiting for file changes before starting ... I'm also getting this issue while using oak server with denon. PS: I use deno v1.3.1 and windows 10 |
Hey, guys,
deno 1.4.6 |
Same Problem on Windows 10 Pro.
deno 1.4.6 |
|
I had a similar issue to this. I made a simple oak server which just returns "Hello World" and whenever I would make a change and restart the server, I would get the AddrInUse error My Code:server.ts import * as log from "https://deno.land/std@0.77.0/log/mod.ts";
import { Application, Router, RouterContext } from "https://deno.land/x/oak@v6.3.2/mod.ts";
const app = new Application();
const router = new Router();
router.get('/', (ctx: RouterContext) => {
ctx.response.body = "Hello World";
});
app.use(router.routes());
app.use(router.allowedMethods());
app.addEventListener('listen', ({ hostname, port, secure }) => {
log.info(`Listening on ${secure ? 'https://' : 'http://'}${hostname || "localhost"}:${port}`)
});
await app.listen({ port: 3000 }); scripts.json {
"$schema": "https://deno.land/x/denon/schema.json",
"scripts": {
"start": {
"cmd": "deno run server.ts",
"allow": ["net"],
"desc": "run my app.ts file"
}
},
"logger": {
"quiet": false,
"debug": true
}
} Error Log:[*] [main] v2.4.4
[*] [daem] watching path(s): *.*
[*] [daem] watching extensions: ts,tsx,js,jsx,json
[!] [#0] starting `deno run --allow-net server.ts`
[&] [#0] starting process with pid 17392
[&] [daem] monitoring status of process with pid 17392
Listening on http://localhost:3000
[&] [path] trying to match server.ts
[&] [path] path server.ts is matched
[&] [path] trying to match server.ts
[&] [path] path server.ts is matched
[&] [daem] reload event detected, starting the reload procedure...
[*] [daem] restarting due to changes...
[&] [daem] killing 1 orphan process[es]
[&] [daem] closing (windows) process with pid 17392
[*] [daem] watching path(s): *.*
[*] [daem] watching extensions: ts,tsx,js,jsx,json
[!] [#0] starting `deno run --allow-net server.ts`
[&] [#0] starting process with pid 15416
[&] [daem] monitoring status of process with pid 15416
[&] [daem] error getting status of process with pid 17392
[&] [daem] process with pid 17392 was killed
Check file:///C:/Users/{{USER}}/Programming/Deno/survey-app/server.ts
error: Uncaught AddrInUse: Only one usage of each socket address (protocol/network address/port) is normally permitted. (os error 10048)
at processResponse (core.js:224:13)
at Object.jsonOpSync (core.js:248:12)
at opListen (deno:cli/rt/30_net.js:32:17)
at Object.listen (deno:cli/rt/30_net.js:207:17)
at Application.serve (server.ts:287:25)
at Application.listen (application.ts:362:20)
at server.ts:17:11
[&] [daem] got status of process with pid 15416
[&] [daem] process with pid 15416 exited on its own
[E] [daem] app crashed - waiting for file changes before starting ... What I did:I decided to try and figure out what the issue was by pulling the code from the github repo and modifying it locally. After pulling, I took a quick look over the code and ran C:\Users\{{USER}}\Programming\Deno\survey-app>denon start
[*] [main] v2.4.4
[*] [daem] watching path(s): **/*.*
[*] [daem] watching extensions: ts,tsx,js,jsx,json
[!] [#0] starting `deno run --allow-net server.ts`
[&] [#0] starting process with pid 23148
[&] [daem] monitoring status of process with pid 23148
INFO Listening on http://localhost:3000
[&] [path] trying to match server.ts
[&] [path] path server.ts is matched
[&] [path] trying to match server.ts
[&] [path] path server.ts is matched
[&] [daem] reload event detected, starting the reload procedure...
[*] [daem] restarting due to changes...
[&] [daem] killing 1 orphan process[es]
[&] [daem] closing (windows) process with pid 23148
[*] [daem] watching path(s): **/*.*
[*] [daem] watching extensions: ts,tsx,js,jsx,json
[!] [#0] starting `deno run --allow-net server.ts`
[&] [#0] starting process with pid 21312
[&] [daem] monitoring status of process with pid 21312
[&] [daem] error getting status of process with pid 23148
[&] [daem] process with pid 23148 was killed
Check file:///C:/Users/{{USER}}/Programming/Deno/survey-app/server.ts
INFO Listening on http://localhost:3000
[&] [path] trying to match server.ts
[&] [path] path server.ts is matched
[&] [path] trying to match server.ts
[&] [path] path server.ts is matched
[&] [daem] reload event detected, starting the reload procedure...
[*] [daem] restarting due to changes...
[&] [daem] killing 1 orphan process[es]
[&] [daem] closing (windows) process with pid 21312
[*] [daem] watching path(s): **/*.*
[*] [daem] watching extensions: ts,tsx,js,jsx,json
[!] [#0] starting `deno run --allow-net server.ts`
[&] [#0] starting process with pid 15332
[&] [daem] monitoring status of process with pid 15332
[&] [daem] error getting status of process with pid 21312
[&] [daem] process with pid 21312 was killed
Check file:///C:/Users/{{USER}}/Programming/Deno/survey-app/server.ts
INFO Listening on http://localhost:3000 |
Still the same os error 10048 on Windows 10 Pro with Denon v2.4.4 :( Windows 10 Pro 20H2 |
I get this bug too, @MustachedNinja Can you offer a PR to fix this issue? I noticed this bug happens when I set a // scripts.config.ts
import { DenonConfig } from "https://deno.land/x/denon/mod.ts";
const config: DenonConfig = {
env: {
DENO_DIR: "./deno_dir",
},
scripts: {
cache: {
cmd: "deno cache src/index.ts --lock-write",
desc: "Caches all deps and locks them in .lock file",
lock: "./lock.json",
watch: false,
},
serve: {
cmd: "deno run src/index.ts",
desc: "run my app.ts file in DEV mode",
watch: true,
allow: {
net: true,
},
env: {
DEV: "true",
},
},
start: {
cmd: "deno run src/index.ts",
desc: "run my app.ts file in PROD mode",
allow: {
net: true,
},
watch: false,
},
},
watcher: {
exts: ["js", "ts", "json"],
match: ["src/**/*.*"],
skip: ["./lock.json"],
},
};
export default config; |
I finally had some free time to take a look at the bug, and it looks like it was patched in version 2.4.5 |
I can confirm, that it works with 2.4.5 on W10. |
Having the same issue also with Win 10, Deno 1.6.2, Denon 2.4.5 |
Same issue with
|
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. if (Deno.build.os === "windows") {
logger.debug(`closing (windows) process with pid ${p.pid}`);
p.close(); // This original line does NOT end the process.
p.kill(9); // <<<<<< This added line DOES end the Windows process.
} else {
logger.debug(`killing (unix) process with pid ${p.pid}`);
p.kill(9);
} 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 |
Hi, I have the same problem again. I have tested several startup configurations but nothing works. Furthermore, I also tried to downgrade Deno to 1.6.3, but I have another error:
Edit: for the error with Deno 1.6.3, I found #122. |
Same problem than last year. Deno 1.9.0. Denon 2.4.7. Windows 10 Pro (1.0.0.19041) scripts.json {
"$schema": "https://cdn.deno.land/denon/versions/2.4.7/raw/schema.json",
"scripts": {
"dev":{
"watch": true,
"allow": ["net", "read", "write", "env"],
"cmd": "deno run --unstable ./Server/Server.ts",
"log": "info",
"env": {
"isdev":"dev"
}
},
"compile": {
"watch": false,
"cmd": "deno compile --unstable --allow-net --allow-read --allow-write --allow-env ./Server/Server.ts"
}
},
"watcher": {
"interval": 500,
"exts": [
"ts",
"tsx",
"json"
]
}
} Server.ts import { Application } from "https://deno.land/x/oak/mod.ts";
const app = new Application();
app.use(async (context)=>{
await context.send({
root: `${Deno.cwd()}/Client/Dist/`,
index: 'index.html'
})
})
console.log("App listening to http://localhost:8080")
await app.listen("localhost:8080"); Console screen (first launch & reload with save) |
The error occurs only with Oak for me. I tried to compare other HTTP modules, but I can't find anything strange. The process closes every other time. With the command |
For me it also occurs with the built-in deno http module (and with oak too). I finished by writing my own watch script like so : const watcher = Deno.watchFs("./Server");
let LastReload : Date = new Date();
let Process : Deno.Process
Launch_Process()
for await (const event of watcher){
if((LastReload.getTime() + 1000) < new Date().getTime()){
LastReload = new Date()
Kill_Process()
Launch_Process()
}
}
function Launch_Process(){
Process = Deno.run({
cmd: ["deno", "run", "--unstable", "-A", "Server/Server.ts"]
})
}
function Kill_Process(){Process.close()} And everything work well now. |
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

The text was updated successfully, but these errors were encountered: