@Isaac You bring up a good point about the duplex streams, I can see how 
that could get hairy real quick.

Your domains example is nice, so maybe that is the best way to handle error 
in a single place.


For completeness and finishing the discussion around this, I can give one 
last idea. Since pipe takes an options object, what if we added a new flag 
like 'forwardError' which defaults to false, but if it is set true then 
would propagate the error if there is a destination error handler? A user 
would only want to do this on one directional streams.

The resulting code would look like:

rstream                                            // input stream coming 
in to http server
  .pipe(digestStream, { forwardError: true })      // calculates the sha1
  .pipe(zlib.createGzip(), { forwardError: true }) // compress the data
  .pipe(redisWStream, { forwardError: true })      // store it in db
  .on('error', handleError)        // will respond back to user with 
appropriate message for error
  .on('end', storeDigestMetaInDB); // record the digest in meta info in db  
 

It is not nearly as clean with the extra option to each pipe.


Is this of any use, being able to selectively choose to forward for the 
cases when you know you are using single direction streams? OR should we 
just steer always everyone towards using domains (or individual error 
handlers)?


I'm thinking that maybe the domains approach is better since it is more 
foolproof, and you don't have to worry about whether duplex and you catch 
all errors that are thrown (not just the emitted ones).


Any last thoughts before we lay this to rest?


Thanks to everyone for all your input!

Jeff

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to