stream: check _events before _events.error

This fixes the regression introduced by 5458079, which breaks the
net/net-pipe benchmark script.

Closes #6145
This commit is contained in:
isaacs 2013-08-28 09:35:36 -07:00
parent 02eb9c834a
commit fbb963b5d5

View File

@ -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);