Skip to content

Trace.fromRequest in Trace.js fails when using Unix Socket instead of TCP/IP Network Socket #36

@radkins3141

Description

@radkins3141

In Trace.fromRequest in the file lib/trace.js, a variable called 'host' is unprotected when function call 'request.socket.address()' returns null, resulting in an error later when host.address is dereferenced during the construction of a new Endpoint. This is because, within the request.socket.address function, a native code function called 'getsockname' is undefined on the internally used 'request.socket._handle' object when associated with a Unix Socket. In contrast, getsockname is properly defined (by node.js) and can be found when the request is associated with a TCP/IP socket. A sample fix for Trace.fromRequest could be to protect the 'host' variable with a slight modification to the current code similar to the following:

var hostAddress = null;
if (request.socket && request.socket.address) {
   hostAddress = request.socket.address();
}
// Note hostAddress can be set to null when using a Unix instead of a TCP/IP Socket
var host =  hostAddress ? hostAddress : {address: '127.0.0.1', port: 80};

[ Please note I'm using node v0.10.26 in an Ubuntu 15.04 environment. Thank's in advance for looking at this issue. ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions