Cannot read property 'connection' of undefined #17

Closed
jiehanzheng opened this Issue Feb 17, 2013 · 3 comments

Comments

Projects
None yet
4 participants
Contributor

jiehanzheng commented Feb 17, 2013

Looks like these four lines are causing problems under some circumstances. It happens rarely but @ym and I can confirm that it does happen once in a while. I will update this issue when I find a way to reproduce.

console.log("%s:%s".yellow + " - %s - " + "stream ID: " + "%s".yellow,
  socket.connection ? socket.connection.socket.remoteAddress : socket.socket.remoteAddress,
  socket.connection ? socket.connection.socket.remotePort : socket.socket.remotePort,
  req.method, res.streamID || socket.streamID
);

Stack trace:

< Uncaught TypeError: Cannot read property 'connection' of undefined
<     at [object Object].handleRequest (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:110:13)
<     at [object Object].emit (events.js:99:17)
<     at Connection.onrequest (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/spdy/lib/spdy/server.js:96:14)
<     at Connection.emit (events.js:99:17)
<     at HTTPParser.onIncoming (http.js:1889:12)
<     at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
<     at Stream.ondata (http.js:1786:22)
<     at Stream.<anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/spdy/lib/spdy/server.js:441:27)
< ----------------------------------------
<     at EventEmitter.on
<     at new <anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:154:8)
<     at new <anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/lib/server.js:160:10)
<     at Object.<anonymous> (/mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/bin/spdyproxy:86:13)
<     at Module._compile (module.js:449:26)
<     at Object..js (module.js:467:10)
<     at Module.load (module.js:356:32)
<     at Function._load (module.js:312:12)
<     at Object._onTimeout (module.js:492:10)
< Uncaught undefined
< Uncaught undefined
< Uncaught undefined
< /mnt/docs/jiehan/Dropbox/workspace/node-spdyproxy/node_modules/long-stack-traces/lib/long-stack-traces.js:80
<                     throw ""; // TODO: throw the original error, or undefined?
<                     ^
program terminated

Could this be because that socket.connection is changing from something to undefined precisely at a time between the ?-evaluation and socket.connection.socket.*? (Obviously, I don't really know how async the whole thing is.)

In other words, would the following change anything?

conn = socket.connection;
console.log("%s:%s".yellow + " - %s - " + "stream ID: " + "%s".yellow,
  conn ? conn.socket.remoteAddress : socket.socket.remoteAddress,
  conn ? conn.socket.remotePort : socket.socket.remotePort,
  req.method, res.streamID || socket.streamID
);
Owner

igrigorik commented Mar 23, 2013

@jiehanzheng @henrypijames can you guys try the latest release?

igrigorik closed this May 27, 2013

wernight commented Oct 1, 2016 edited

Seeing this error as well running on Alpine Linux. Not sure why yet. Same on Debian works.

Create issue #66 as the error is slightly different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment