-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Restart with --inspect flag fails with port in use error #1346
Comments
Please provide a git repo to replicate from. I'm not going to guess at the package config (and I've used inspect with nodemon with success, so the config is what I'm after). |
Also, if you have a suggestion, best to provide a PR with a test showing it works, that would be absolutely 👍 |
I'll think how can I create an isolated project that can be used to reproduce that, but it seems to be very challenging, here I can reproduce inside docker containers since I can reduce the resources available from my computer to execute the app. |
Maybe you'll be able to debug your project directly (and I suspect there's something special about the project that's causing the issue, but I know others have seen something vaguely similar, but never able to replicate). You can also use |
I'm also seeing this error randomly, while using nodemon inside a Docker container. The error is completely random, I'm not able to create a repro scenario. I tried adding a This is the log of a successful restart:
This is the log of the failure:
Let me know if I can assist further. |
Maybe retry the spawn until the port is available would be a good workaround until we find the issue that is causing the port to be in use for more time then the |
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. |
I'm also running into this inside of a Docker container (Docker for Windows) |
Hi @remy, i'm experiencing this issue too as well as the others Node: 9.10.1 Here is a link to my repo: https://github.com/AlexanderYW/uptime |
Can we mark this as worked around (I suspect the fact it's nodemon plus node plus debugger protocol plus docker plus host system - might make the inception like debugging silly hard - certainly no one has offered any PRs, so I'm guessing I'm right on that one). I'm happy to add this to the faq too. |
(added to faq) |
Here is a repo that replicates this issue: https://github.com/darkobits/nodemon-restart-issue. It seems that Nodemon isn't waiting for the old process to completely exit before starting a new one, but only when in a Docker container and only when debug mode is active. To be clear: The presence of I hope this helps. P.S. -- 👏 to Remy and the other contributors to this fantastic project. 😸 |
@darkobits you're better off starting a new issue for what you're seeing (particularly useful as you have a repo to replicate). I prefer to work with fresh issues (particularly when there's been a bunch of time since closing and reporting new findings). Thans again for the repo to replicate 👍 |
This happens to me outside of docker: https://github.com/nomcopter/nodemon-no-wait-repro |
Adding |
@Christilut When im adding the signal SIGINT to the nodemon.json it keeps restarting, the errrors are gone but this is also not a good solution. Do you have any idea why the signal sigint can cause this? |
No idea but this is the full config I'm using, maybe it helps: nodemon.json {
"restartable": "rs",
"ignore": [
".git",
"node_modules/**/node_modules"
],
"verbose": false,
"execMap": {
"ts": "node --require ts-node/register"
},
"watch": [
"server/",
"config/"
],
"ext": "json,ts",
"signal": "SIGINT"
} Start with (as NPM script): |
So the trick with fuser kinda worked for me, here is my solution:
Hope this helps someone in the future |
Bizarrely changing the signal to |
After using SIGINT, nodemon restarts but can't kill the process when debugger is attached and process is paused (i.e. user is currently stepping via code): my package.json configuration:
|
I have some additional information that will hopefully prove useful to somebody. The issue only occurred when the app was paused on a debug breakpoint, then made a file change and saved. The debugger was not releasing the port connection, and nodemon was not forcing it to close. After finding the solution mentioned by @Christilut, I cycled through the possible signals to see which performed as expected. I found the behavior on the following signals:
For me SIGKILL is the fastest/most stable. |
nodemon -v
: 1.17.4node -v
: v10.1.0nodemon --expose-gc --inspect=0.0.0.0:9228 --legacy-watch --delay 250ms --watch webpack.config.js node_modules/.bin/webpack-dev-server --mode development --host 0.0.0.0 --port 80
Expected behaviour
When a file has changed, it should restart the node application, with the following steps "stop the current application; start the a new instance of the application"
Actual behaviour
It's starting the application before the previous instance finish to stop, what makes it to fail and display the following error:
If any the watched file get's changed, it restart again and it work since it will be enough time to stop the application instance.
Steps to reproduce
Start a simple project with webpack-dev-server, babel and react, then add a dummy
src/index.js
that initialize react to make the process be a bit slower for webpack-dev-server.Start the nodemon using the command provided.
execute:
touch webpack.config.js
it might fail if your computer isn't fast enough to stop the instance before start the next.Suggestion
Listen for the PID to be dead before start a new instance using a timeout or interval when
--inspector
flag is added tonodemon
, to be sure that all resources are available before starting a new instance.If applicable, please append the
--dump
flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.The text was updated successfully, but these errors were encountered: