diff --git a/lib/http.js b/lib/http.js index c2f6e18741..8c7658ea4b 100644 --- a/lib/http.js +++ b/lib/http.js @@ -1244,9 +1244,15 @@ Agent.prototype._establishNewConnection = function() { parser.onIncoming = function(res, shouldKeepAlive) { debug('AGENT incoming response!'); - var req = socket._httpMessage; - assert(req); + // If we're receiving a message but we don't have a corresponding + // request - then somehow the server is seriously messed up and sending + // multiple responses at us. In this case we'll just bail. + if (!socket._httpMessage) { + socket.destroy(); + return; + } + var req = socket._httpMessage; req.res = res; // Responses to HEAD requests are AWFUL. Ask Ryan.