Skip to content

Commit

Permalink
Handle DNS lookup failures (#439)
Browse files Browse the repository at this point in the history
When lookup fails, it throws an exception, that prevent other code from being executed

fixes #437
  • Loading branch information
just-boris authored and leo committed Jul 2, 2018
1 parent 250c972 commit dd3704f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,14 @@ const startEndpoint = (endpoint, config, args) => {
localAddress = details;
} else if (typeof details === 'object' && details.port) {
const address = details.address === '::' ? 'localhost' : details.address;
const {address: ip} = await lookup(os.hostname());

localAddress = `http://${address}:${details.port}`;
networkAddress = `http://${ip}:${details.port}`;
try {
const {address: ip} = await lookup(os.hostname());
networkAddress = `http://${ip}:${details.port}`;
} catch (err) {
console.error(error(`DNS lookup failed: ${err.message}`));
}
}

if (isTTY && process.env.NODE_ENV !== 'production') {
Expand Down

0 comments on commit dd3704f

Please sign in to comment.