app: send port:0 instead of port:undefined

Node v6 no longer supports port:undefined, this commit is fixing
app.listen() to correctly send port:0 when no port is specified.
This commit is contained in:
Miroslav Bajtoš 2016-05-03 16:03:48 +02:00
parent bd7f2b6db1
commit da2fb0ae15
1 changed files with 5 additions and 1 deletions

View File

@ -566,7 +566,11 @@ app.listen = function(cb) {
(arguments.length == 1 && typeof arguments[0] == 'function');
if (useAppConfig) {
server.listen(this.get('port'), this.get('host'), cb);
var port = this.get('port');
// NOTE(bajtos) port:undefined no longer works on node@6,
// we must pass port:0 explicitly
if (port === undefined) port = 0;
server.listen(port, this.get('host'), cb);
} else {
server.listen.apply(server, arguments);
}