stream: check _events before _events.error
authorisaacs <i@izs.me>
Wed, 28 Aug 2013 16:35:36 +0000 (09:35 -0700)
committerisaacs <i@izs.me>
Wed, 28 Aug 2013 16:35:39 +0000 (09:35 -0700)
This fixes the regression introduced by 5458079, which breaks the
net/net-pipe benchmark script.

Closes #6145

lib/_stream_readable.js

index 368c923..fd63969 100755 (executable)
@@ -519,7 +519,7 @@ Readable.prototype.pipe = function(dest, pipeOpts) {
   }
   // This is a brutally ugly hack to make sure that our error handler
   // is attached before any userland ones.  NEVER DO THIS.
-  if (!dest._events.error)
+  if (!dest._events || !dest._events.error)
     dest.on('error', onerror);
   else if (Array.isArray(dest._events.error))
     dest._events.error.unshift(onerror);