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 462cec4c1c
commit 4d7154a31a
1 changed files with 5 additions and 1 deletions

View File

@ -565,7 +565,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);
}