Skip to content

Commit

Permalink
fix: ignore EADDRNOTAVAIL error when listen localhost (#33)
Browse files Browse the repository at this point in the history
if localhost refer to the ip that is not unkonwn on the machine, you will see the error EADDRNOTAVAIL

https://stackoverflow.com/questions/10809740/listen-eaddrnotavail-error-in-node-js
  • Loading branch information
popomore authored and fengmk2 committed May 16, 2018
1 parent 17ffc37 commit 64777f8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
@@ -1,10 +1,10 @@
sudo: false
language: node_js
node_js:
- 4
- 6
- 7
- 8
- '4'
- '6'
- '8'
- '10'
install:
- npm i npminstall && npminstall
script:
Expand Down
10 changes: 5 additions & 5 deletions appveyor.yml
@@ -1,9 +1,9 @@
environment:
matrix:
- nodejs_version: 4
- nodejs_version: 6
- nodejs_version: 7
- nodejs_version: 8
- nodejs_version: '4'
- nodejs_version: '6'
- nodejs_version: '8'
- nodejs_version: '10'

install:
- ps: Install-Product node $env:nodejs_version
Expand All @@ -12,6 +12,6 @@ install:
test_script:
- node --version
- npm --version
- npm run ci
- npm run test

build: off
4 changes: 3 additions & 1 deletion lib/detect-port.js
Expand Up @@ -56,7 +56,9 @@ function tryListen(port, maxPort, callback) {

// 3. check localhost
listen(port, 'localhost', err => {
if (err) {
// if localhost refer to the ip that is not unkonwn on the machine, you will see the error EADDRNOTAVAIL
// https://stackoverflow.com/questions/10809740/listen-eaddrnotavail-error-in-node-js
if (err && err.code !== 'EADDRNOTAVAIL') {
return handleError(err);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -39,7 +39,7 @@
"node": ">= 4.2.1"
},
"ci": {
"version": "4, 6, 7, 8"
"version": "4, 6, 8, 10"
},
"homepage": "https://github.com/node-modules/detect-port",
"license": "MIT"
Expand Down

0 comments on commit 64777f8

Please sign in to comment.