Skip to content
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

nodemon do not kill older process. #1435

Closed
sandinocoelho opened this issue Oct 12, 2018 · 17 comments
Closed

nodemon do not kill older process. #1435

sandinocoelho opened this issue Oct 12, 2018 · 17 comments
Labels
missing code to replicate Can't replicate the issue until there is sample code

Comments

@sandinocoelho
Copy link

sandinocoelho commented Oct 12, 2018

  • nodemon -v: 1.18.4
  • node -v: 8.12.0
  • Operating system/terminal environment: Ubuntu 18.04
  • Command you ran: nodemon app.js

Expected behaviour

When I make some changes to the code, the expected behaviour is that the node will kill the node process and create a new one.

Actual behaviour

nodemon creates a new process but does not kill the old process and because of this, I have a conflict between ports.

Steps to reproduce

$ nodemon app

change some file in the project

Error Message:

[nodemon] restarting due to changes...
[nodemon] starting `node app`
consign v0.1.6 Initialized in /home/sandino/Projects/udemy_nodejs/Portal de Noticias
+ ./app/routes/admin.js
+ ./app/routes/home.js
+ ./app/routes/noticias.js
+ ./config/dbConnection.js
+ ./app/models/NoticiasDAO.js
+ ./app/controllers/admin.js
+ ./app/controllers/home.js
+ ./app/controllers/noticias.js
events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3002
    at Server.setupListenHandle [as _listen2] (net.js:1360:14)
    at listenInCluster (net.js:1401:12)
    at Server.listen (net.js:1485:7)
    at Function.listen (/home/sandino/Projects/udemy_nodejs/Portal de Noticias/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/home/sandino/Projects/udemy_nodejs/Portal de Noticias/app.js:4:5)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
[nodemon] app crashed - waiting for file changes before starting...

Ctrl + C

$ lsof -i :3002

COMMAND   PID    USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
node    21441 sandino   11u  IPv6 1327282      0t0  TCP *:3002 (LISTEN)

*This is the first time I write an issue. Forgive me if any information was missing.

@bke-daniel
Copy link

bke-daniel commented Oct 15, 2018

Saldy, same for me.
nodemon 1.18.4 node 10.12.0

EDIT:
A few more infos:
In general, it doesn't happen on every change within my dist folder. The issue did not appear once on node version 10.11.0 which I updated to today.
Rolled back to LTS version 8.12.0 (which was on my roadmap anyway) and the issue seems to be gone.
So maybe it's just a version 10.12.0 thingy

@rveitch
Copy link

rveitch commented Oct 21, 2018

Also happening here:
nodemon 1.18.4 node 8.11.1

I'm not on 10.12.0, so not sure it's that. I am on OSX.

I'm not sure if nodemon is attempting to restart before the PID kill has completed, but in my tests it looked like that might be the case. I checked the PID before a restart and had the app log out the PID when SIGUSR2 was called. As you can see from the screenshot, PID was called and then then the EADDRINUSE error was thrown, but after checking the PID's again, nodemon was had actually succeeded in restarting and a process WAS active.

image

@samuelopra
Copy link

I also have this issue Nodemon v1.18.4

@stale
Copy link

stale bot commented Nov 17, 2018

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.
Thank you for contributing <3

@stale stale bot added the stale no activity for 2 weeks label Nov 17, 2018
@abdullahtariq1171
Copy link

Same issue with "nodemon": "^1.18.6"

@stale stale bot removed the stale no activity for 2 weeks label Nov 22, 2018
@remy
Copy link
Owner

remy commented Nov 22, 2018

Um…no one has actually provided an app.js to replicate with. Without that, it can't be replicated and can't be debugged.

@remy remy added the missing code to replicate Can't replicate the issue until there is sample code label Nov 22, 2018
@ellefsen
Copy link

I have this example set up - https://codesandbox.io/s/o4wzoqk9o6
It runs fine in the sandbox, but if I download it and run it on my mac it will fail with Error: listen EADDRINUSE :::8080

Tried running in both my default environment and with the sandbox versions. Both fail.
Node v10.6.0|v8.11.2
NPM 6.1.0|5.6.0

Mac OS 10.13.6 - shell: zsh 5.3 (x86_64-apple-darwin17.0)

@zoman2000
Copy link

Same problem here.
Here is the sample "project" - https://gitlab.com/alexsmit/sample. Tried to create as smaller project as possible. I hope it will help.

(not expected): If you modify server index.js, save it you will get a mentioned above error. And event not captured :(
(expected): If you modify client code (react, excluded) works fine because it is excluded.

Environment: Linux, Node 8.11.4

@mkgo
Copy link

mkgo commented Nov 25, 2018

I tried multiple things thinking it might of been my environment but I am seeing the same thing even after a clean ubuntu 18.04 install.

Getting EADDRINUSE 127.0.0.1:1337 on file change. (Ctrl+C and restart works).

  • using nvm nvm install -lts ( node -v = v10.13.0 also tried on v8.13.0 )
  • npm v 6.4.1
  • yarn 1.12.3 is installed (tried installing with npm and yarn thinking it might of been yarn)
  • tried nodemon global and local installs

Can't get it to update on change without crashing.

@remy
Copy link
Owner

remy commented Nov 27, 2018

Fairly sure this is directly related to #1459 et al. nodemon@1.18.7 fixes it.

Please test with latest (currently being released) and let me know if it's not fixed (and please include tests and PR to contribute).

@remy remy closed this as completed Nov 27, 2018
@zoman2000
Copy link

Working for me. Thanks !!!!

@mkgo
Copy link

mkgo commented Nov 27, 2018

Just to confirm that 1.18.7 indeed fixed the problem for me. Thanks.

@zverbeta
Copy link

zverbeta commented Dec 8, 2018

Working too. Thanks

@nicklasring
Copy link

nicklasring commented May 21, 2019

events.js:174
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::8088
    at Server.setupListenHandle [as _listen2] (net.js:1270:14)

Version 1.19.0 still not exiting correctly

@aodr3w
Copy link

aodr3w commented Nov 18, 2019

Having the same problem with version 1.19.4
app.js
const PORT = process.env.PORT || 8000;

app.listen(PORT, () => {
console.log(Server started on port ${PORT});
});

@VladKomarov
Copy link

I figured out that after code change not only node process still running, but the parent nodemon process too. Try killing both nodemon parent and node proccesses and rerun nodemon. For now it helped me, but it happened not first time.

@Bec-k
Copy link

Bec-k commented Aug 4, 2020

same here in v2.0.4

Repository owner locked and limited conversation to collaborators Aug 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
missing code to replicate Can't replicate the issue until there is sample code
Projects
None yet
Development

No branches or pull requests