-
-
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
pstree vuln / pstree upgrade / Error: listen EADDRINUSE: address already in use #1463
pstree vuln / pstree upgrade / Error: listen EADDRINUSE: address already in use #1463
Comments
Same behavior with lts/boron and lts/carbon. Tried with nodemon 1.18.x & 1.17.x. Also happens when Debian 4.18.10-2 x86_64 Strange. Edit: Edit2: I am now using a bootstrap.js instead of the -r flag yet I still get the above error when restarting (simple edit). There is a db conn and an http server in the app. It feels like the server holds onto the db conn and thus nodemon can't terminate it. |
The problem is in If you go to |
Okay, I'm finally able to replicate. It needs nodemon to be spawned inside of an |
Replicating using this https://github.com/remy/nodemon-test-cases/tree/master/1466 |
The fix unfortunately did not resolve my problem with the EADDRINUSE on reload. On first start, everything runs fine:
After reloading a file (here src/server.ts) I get the EADDRINUSE error.
My nodemon.json:
I use docker 18.09.0 on OSX running the node-alpine image v10.13.0. Also as you an see from the nodemon json I use the exec-flag to run ts-node. Node application does not do much but has a connection to mongodb if this matters. -act |
It probably does. My guess is that you're not closing off the connection to mongo cleanly so the sub process remains. You'll need to provide a parred down example, ideally with little to zero dependencies to keep the example simple |
I checked another node app that does not use any db connections and it still throws the error. Maybe it has something to do with ts-node or the polling options. I will investigate further why the process is not removed entirely.
|
Thank you.
…On Tue, 27 Nov 2018, 10:38 Rocco Di Leo, ***@***.***> wrote:
I checked another node app that does not use any db connections and it
still throws the error. Maybe it has something to do with ts-node or the
polling options. I will investigate further why the process is not removed
entirely.
yarn run v1.12.3
$ nodemon -L --polling-interval 1000
[nodemon] 1.18.7
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 18 to restart
[nodemon] ignoring: ./dist/**/* ./secrets/**/* ./.git/**/* ./node_modules/**/* ./src/public/**/*
[nodemon] watching: /app/src/**/*
[nodemon] watching extensions: ts,js,json
[nodemon] starting `ts-node --files ./src/server.ts`
[nodemon] spawning
[nodemon] child pid: 30
[nodemon] watching 14 files
[info] server listening on: 3112
[nodemon] files triggering change check: src/server.ts
[nodemon] matched rule: /app/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/server.ts
2018-11-27T10:22:35.895880142Z
[nodemon] starting `ts-node --files ./src/server.ts`
[nodemon] spawning
[nodemon] child pid: 40
[info] server listening on: 3112
Error: listen EADDRINUSE :::3112
at Server.setupListenHandle [as _listen2] (net.js:1286:14)
at listenInCluster (net.js:1334:12)
at Server.listen (net.js:1421:7)
at Object.<anonymous> (/app/src/server.ts:21:12)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Module.m._compile (/app/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.require.extensions.(anonymous function) [as .ts] (/app/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
[nodemon] app crashed - waiting for file changes before starting...
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#1463 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAA1hFwVTC01ZEUfHlUTEZO0oXNqP2h2ks5uzRYJgaJpZM4Yx9n->
.
|
I can also confirm that upgrading nodemon to 1.18.7 didn't solve the issue.
p.s. The app I tried it on also uses a mongodb connection. Mongoose to be exact. Edit: |
Can you reduce the issue so we can replicate it, or can you debug and send a PR? |
Just to add: the original issue raised is solved - I could replicate with the details provided. So this new issue, I suspect is related or similar, but needs bits to replicate |
I stripped down my index.js to:
I have the following package setup:
I run
Created a project with just |
I checked what processes where actually involved when running nodemon in my docker container. On startup it looks like this, take note of pid 45+46. pid 45 is what nodemon reports as being the child pid.
When I change and save a file, process 45 is killed which is probably what nodemon does. However, Pid 46 is still left behind and i get the EADDRINUSE-error.
When I kill PID 46 in the docker container manually using 'kill -9 46', I can actually change a watched file and the app reloads on save as expected without throwing EADDRINUSE. I am no expert on process handling on linux, so I actually don't even know why two pids are involved here. Maybe someone more proficient can shed some light on this? I tend to believe this is due to the exec-command usage. Greets |
Can you replicate with Babel removed? |
I tried with vanilla http, basic express, and express+mongoose. First two work fine. I actually think mongoose is the culprit here. I can't investigate further (at least today) because I have to power through something. Here is a hacky thing I had to do, though, might be related. I'd have tried it with a couple more db drivers if I had the time. Please bring nodemon back @remy, I didn't realize how much I depend on it. Edit: I also get one extra db connection (process) when nodemon tries to restart. I am guessing a fresh process is .fork'ed before terminating the old one? Old one refuses to be terminated. |
In my case it's not a db-connection but the second not terminated ts-node process as described in #1463 (comment) My workaround now is this additional configuration entry in nodemon.json which uses an sh-command to identify the process and kills it. Installing the kill-all package as recommended above did not work for me.
Greets |
Tried the initial app with node-dev. Same thing happens. Again with node 8 & 10 lts. Here is the dependencies for node-dev; {
dateformat: '~1.0.4-1.2.3',
'dynamic-dedupe': '^0.2.0',
filewatcher: '~3.0.0',
minimist: '^1.1.3',
'node-notifier': '^4.0.2',
resolve: '^1.0.0'
} I don't see any commonality with nodemon. Node versions do not seem to matter, also. Maybe this issue is related to the new linux kernel? I think everyone uses it, nowadays. |
Once we've bumped nodemon to 1.18.6 in the nodemon-webpack-plugin, our tests started failing due to the issue in this ticket. That meant we had to disable tests in order to publish the new version of the plugin. I take it no test in this repo caught this issue. I'm writing this to say that there are already tests for the plugin to would catch this issue. All the groundwork has already been done. So maybe it is worth copying these across with slight modifications (you'll have to spawn nodemon rather than webpack)? |
@Izhaki have you bumped to 1.18.7? That's the latest with these fixes in it? |
Thankfully I've landed on this issue and bumped to 1.18.7 - I was already on course to spending days on this! (On Monday eve we've bumped to 1.18.6 but had to disable the tests in order to publish; last night we've bumped to 1.18.7 and reinstated the tests). Have a look at the tests for the plugin and let me know if you think porting them here is viable. |
@remy I was unable to replicate without babel as a dependency. I realized somehow I was still on 1.18.4 updated to 1.18.7 and it resolved my experience. |
This is a tricky, hard-to-reproduce bug. The initial app (http & mongo) worked with nodemon for a couple hours. Then it started throwing the above error. I'm not sure how it got to that state. While things were working, I fired up a vscode debugger that runs Also, when I hit the error, I had added a simple So, if I restore the script to its clean state, I can re-attach the port. Any code edits after that get the erroneous state. I restarted my OS, and now everything seems to be working fine. I think clearing stray (node?) processes has something to do with it. I will be mindful of what I was previously doing if I get the error again. Edit: I can confirm that the vscode debugger is at least one of the reasons for this. It might be my launch.json has errors. The node processes it leaves behind, even if I kill them manually, cause nodemon to re-attach only to the state of the script vscode left it in. Here is my launch.json; {
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
"runtimeArgs": ["--inspect"],
"program": "${workspaceRoot}/bootstrap.js",
"restart": true,
"port": 9229,
"protocol": "inspector",
} Edit2: There seem to be some processed vscode leaves behind that I can't find. I just did |
Experiencing the same on 1.18.7.
|
I have the same experiencing
{
"name": "astoria",
"version": "0.0.1",
"description": "backend part of himself65 official website",
"main": "src/index.js",
"repository": "https://github.com/Himself65/Astoria.git",
"author": "himself65",
"license": "MIT",
"scripts": {
"lint": "eslint ./src/**/*.{js,ts}",
"lint-fix": "lint --fix",
"dev": "nodemon --exec babel-node src/index.js NODE_ENV=development ",
"start": "cross-env pm2 start ecosystem.config.js --env production",
"build": "babel src -d dist",
"test": "node build/run-tests.js",
"test:unix": "cross-env NODE_ENV=test jest",
"test:win32": "cross-env NODE_ENV=test jest -i",
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"axios": "^0.18.0",
"koa": "^2.6.2",
"koa-jwt": "^3.5.1",
"koa-logger": "^3.2.0",
"koa-router": "^7.4.0",
"koa-static": "^5.0.0",
"koa-unless": "^1.0.7",
"koa2-connect-history-api-fallback": "^0.0.6",
"mongoose": "^5.3.15",
"pm2": "^3.2.2",
"sequelize": "^4.41.2",
"url": "^0.11.0"
},
"devDependencies": {
"@babel/cli": "^7.2.0",
"@babel/core": "^7.2.0",
"@babel/node": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.2.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"@babel/runtime": "^7.2.0",
"@types/jest": "^23.3.10",
"@types/koa": "^2.0.47",
"@types/node": "^10.12.12",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"cross-env": "^5.2.0",
"eslint": "^5.9.0",
"eslint-config-standard": "^12.0.0",
"eslint-import-resolver-babel-module": "^4.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"jest": "^23.6.0",
"nodemon": "^1.18.7"
}
} |
@himself65 you need to bump to nodemon@1.18.8 |
cambie el port en y funciono |
My case:
Command: |
I'm running into this issue too. Ubuntu 18.04.2 |
nodemon -v
: 1.18.6node -v
: 11.2.0npm -v
: 6.4.1yarn -v
: 1.12.3nodemon -r ./lib app
I'm running into an EADDRINUSE error with
nodemon
andexpress
since yesterday, which only happens when requiring a module (or file) using-r
from the CLI.Expected behaviour
It should restart the web server when the entry file is saved.
Actual behaviour
It hangs up with
Error: listen EADDRINUSE: address already in use
when the file is saved.Steps to reproduce
yarn init -y
yarn add express
andyarn add -D nodemon
touch app.js
andtouch lib.js
(see file contents below)dev
script inpackage.json
withnodemon -r ./lib app
yarn dev
// lib.js - empty
When I run
yarn dev
from the terminal, and then doCtrl+S
inapp.js
orlib.js
in the editor, I getThe app boots correctly, but as soon as any file changes,
nodemon
can't restart it. In the meantime, the app still continues to run in the background. If I doCtrl+C
, it quits, but there's no more process on port3000
, so killing it by portfuser -k 3000/tcp
doesn't do anything.I found that
yarn
andnpm
, i.e.npm run dev
produces the save errorrequire('./lib')
inapp.js
instead of-r
from the CLIexpress
or any web server (because the port is not used)11.2.0
,11.1.0
, and10.13.0
I discovered this through
esm
when doingnodemon -r esm app
, but later found out that it happens with any file. From that thread, the issue also seems to happen on MacOS as well. Tried rebooting, reinstalling Node, removingyarn.lock
, then removing and re-installingnode_modules
, locking to older versions ofnodemon
, andexpress
... I'm out of options here.I scavenged many threads in this repo with this same error, but to no avail. I hope I'm posting in the right repo this time. Any help is appreciated, thanks!
P.S. Here's the dump with
nodemon -r ./lib app --dump
just in case.Click to expand
The text was updated successfully, but these errors were encountered: