Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
To fix problems arising due to the asynchronous nature of .listen(). Really it should be doing that console.log call inside a callback passed to listen. When the host is added, it tries to do a DNS lookup, which is async. So when that line tries to fetch the address, there isn't one yet because the DNS request is running, so it crashes.
  • Loading branch information
avikpal committed Mar 25, 2014
1 parent 88e8aab commit c652f36
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app.js
Expand Up @@ -427,7 +427,7 @@ app.post('/search.:format?', loadUser, function(req, res) {
});

if (!module.parent) {
app.listen(3000);
console.log('Express server listening on port %d, environment: %s', app.address().port, app.settings.env)
app.listen(3000, 'localhost', function(){
console.log('Express server listening on port %d, environment: %s', app.address().port, app.settings.env)});
console.log('Using connect %s, Express %s, Jade %s', connect.version, express.version, jade.version);
}

0 comments on commit c652f36

Please sign in to comment.