Hi,

I am wondering whats the best way of reading some data from a file stream 
(readable stream) and under a certain condition stop reading? Is it safe to 
e.g. call destroy() from within the on('data') handler? Or do I even have 
to cleanup the stream at all?

Take this example in pseudo code:

var stream = fs.createReadStream(someFile);

stream.on('data', function(data) {
   if (someCondition) {
     stream.destroy();
   }
});

The reason I am asking is because sometimes I am seeing sporadic errors 
like this one and I am trying to hunt it down:

Error: EBADF, read

This is triggered from a on('error') handler on the stream I am reading.

Thanks,
Ben

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to