LearnBoost/socket.io — Issue #614: Transport may be undefined: Cannot read property 'name' of undefined  
Author: tjsingleton
Created: 2011-11-01 16:26:46+00:00
State: open

I'm logging additional information on connect/disconnect. One of the items is the transport. However, it appears in some cases it may be undefined. I am guessing it has to do w\ the "client not handshaken" right before.

I'm only using xhr-polling and jsonp-polling as various antivirus, proxies, and the like break the websocket and flashsocket transports.

Version: socket.io@0.8.6, client being served via socket io.

My code:

manager.sockets.on "connection", (socket) ->
handshake = socket.handshake
address = handshake.address.address
referer = handshake.headers.referer
userAgent = handshake.headers['user-agent']

logger.info "[SOCKET:#{socket.id}] Connection; transport: #{socket.transport}; from: #{address}; referer: #{referer}; user-agent: #{userAgent};"

socket.on "disconnect", ->
logger.info "[SOCKET:#{socket.id}] Disconnect; transport: #{socket.transport}; from: #{address}; referer: #{referer}; user-agent: #{userAgent};"

Problem line: https://github.com/LearnBoost/socket.io/blob/master/lib/socket.js#L74

Backtrace:

[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/socket.js:74:in `Socket.transport'
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/build/lib/socket_server.js:18:in `SocketNamespace.'
events.js:81:in `SocketNamespace.$emit'
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/namespace.js:292:in `connect'
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/namespace.js:308
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/namespace.js:252:in `SocketNamespace.authorize'
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/namespace.js:302:in `SocketNamespace.handlePacket'
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/manager.js:656:in `Manager.handleClient'
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/manager.js:597:in `Manager.handleHTTPRequest'
[PROJECT_ROOT]home/cruncher/echo/releases/20111029021809/node_modules/socket.io/lib/manager.js:559:in `Manager.handleRequest'

Log right before:
w, 11/1 15:57:36.155; client not handshaken client should reconnect
i, 11/1 15:57:36.155; transport end
e, 11/1 15:57:36.176; [Hoptoad] Uncaught Exception: { stack: [Getter/Setter],
arguments: [ 'name', undefined ],
type: 'non_object_property_load',
message: [Getter/Setter] }