You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forever-agent:
function getConnectionName(host, port) {
var name = ''
if (typeof host === 'string') {
name = host + ':' + port
} else {
// For node.js v012.0 and iojs-v1.5.1, host is an object. And any existing localAddress is part of the connection name.
name = host.host + ':' + host.port + ':' + (host.localAddress ? (host.localAddress + ':') : ':')
}
return name
}
_http_agent:
Agent.prototype.getName = function(options) {
var name = options.host || 'localhost';
name +=':';
if (options.port) name += options.port;
name += ':';
if (options.localAddress) name += options.localAddress;
if (options.family === 4 || options.family === 6)
name += ':' + options.family;
return name;
};
Here, given the parameter 'host' in forever-agent.getConnectionName() is object, then:
getConnectionName() will return: 'host:port::'
Here, it has double ':' at the end of result.
getName() will return : 'host:port:'
Here, it has only one ':' and the end of result.
The difference between these two functions will cause the forever-agent throws the error:
TypeError: Cannot read property 'length' of undefined,
at ForeverAgent/index.js:34:34
because self.sockets[name] is undefined.
Should we change to be:
name = host.host + ':' + host.port + ':' + (host.localAddress ? host.localAddress : '');
name += (host.family === 4 || host.family === 6) ? ( ':' + host.family) : '';
The text was updated successfully, but these errors were encountered:
Forever-agent:
function getConnectionName(host, port) {
var name = ''
if (typeof host === 'string') {
name = host + ':' + port
} else {
// For node.js v012.0 and iojs-v1.5.1, host is an object. And any existing localAddress is part of the connection name.
name = host.host + ':' + host.port + ':' + (host.localAddress ? (host.localAddress + ':') : ':')
}
return name
}
_http_agent:
Agent.prototype.getName = function(options) {
var name = options.host || 'localhost';
name +=':';
if (options.port) name += options.port;
name += ':';
if (options.localAddress) name += options.localAddress;
if (options.family === 4 || options.family === 6)
name += ':' + options.family;
return name;
};
Here, given the parameter 'host' in forever-agent.getConnectionName() is object, then:
Here, it has double ':' at the end of result.
Here, it has only one ':' and the end of result.
The difference between these two functions will cause the forever-agent throws the error:
TypeError: Cannot read property 'length' of undefined,
at ForeverAgent/index.js:34:34
because self.sockets[name] is undefined.
Should we change to be:
name = host.host + ':' + host.port + ':' + (host.localAddress ? host.localAddress : '');
name += (host.family === 4 || host.family === 6) ? ( ':' + host.family) : '';
The text was updated successfully, but these errors were encountered: