The ts-node process to be killed.
[start] 🚀 server listening on 0.0.0.0:3000, in development
[start] ⌛ Server started in 1s
[start] [nodemon] restarting due to changes...
[start] [nodemon] starting `ts-node --files src/server.ts`
[start] Error: listen EADDRINUSE: address already in use 0.0.0.0:3000
[start] at Server.setupListenHandle [as _listen2] (net.js:1309:16)
[start] at listenInCluster (net.js:1357:12)
[start] at doListen (net.js:1496:7)
[start] at processTicksAndRejections (internal/process/task_queues.js:85:21)
[start] [nodemon] app crashed - waiting for file changes before starting...
I apologize about the lack of detail and steps to reproduce at the moment. I'll spin up a new environment and see if I can't get it to behave in the same fashion.
I changed my package file to include latest on all dependencies hoping that may help. It did not.
The issue is intermittent so I don't know how to reproduce it at the moment. I'm hoping there's something silly that I did or missed that could solve the issue. I'll update with as much info as I can. If I'm able to pin point exactly what's causing it to hang, I'll update this.
I will most definitely create a reproduction repo. The code is fairly lightweight at the moment, mostly just koa + mongoose for a thin API. The problem started showing up recently. I have no idea what triggered it yet.
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"target": "es6",
"strict": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist"
},
"include": ["src/**/*"]
}
What command are you running to start nodemon? npm run, yarn, are you typing something at your bash shell? Which lines in the log you posted are coming from your app, and which are coming from nodemon? I don't want to assume.
I'm unfamiliar with nodemon. If I understand correctly, nodemon is launching a process, then trying to kill it? This sounds like a nodemon failure, where nodemon is calling process.kill() and somehow not waiting for the process to die.
Have you looked at this thread? Seems like this might be a common nodemon issue with a bunch of solutions: https://github.com/remy/nodemon/issues/1316
I have another suggestion that I can share once you've confirmed answers to the above questions.
@cspotcode Woops, I meant to post my commands, sorry!
nodemon --watch src --ext ts --exec 'ts-node --files src/server.ts'
The thing is it happens with VS Code debug too using the launch.json in the readme:
{
"version": "0.2.0",
"configurations": [
{
"name": "ts-node",
"type": "node",
"request": "launch",
"args": ["${workspaceFolder}/src/server.ts"],
"runtimeArgs": ["-r", "ts-node/register"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
@chanced You mention that it stays alive "on changes." What does VSCode do in that situation? I don't see anything in your VSCode config that restarts on changes.
Did you confirm that this does not happen when you do not use ts-node?
I'll update this if I can ever get it to reproduce on this demo app. So far it's working smoothly.
I'll close this issue for now as it may be unrelated to ts-node.
@chanced This issue is TOTALLY related to ts-node.
It happens even if you run ts-node directly.
Most helpful comment
@chanced This issue is TOTALLY related to ts-node.
It happens even if you run ts-node directly.