npm / fstream

Advanced FS Streaming for Node
ISC License
208 stars 43 forks source link

Reader doesn't propagate errors #31

Closed timbertson closed 9 years ago

timbertson commented 9 years ago

For example, a file which the current user doesn't have access to read. The error listener on the reader itself doesn't see the resulting EACCESS; it just crashes the process.

$ cat fstream-test.js
var fstream = require('fstream');
var devnull = require('fs').createWriteStream('/dev/null');

var reader = fstream.Reader('./stuff');
reader.on('error', function(e) {
    console.warn("Caught error from reader: " + e);
});
reader.pipe(devnull);

$ mkdir stuff
$ sudo bash -c "umask 077; touch stuff/other"
$ ll stuff/
total 0
-rw------- 1 root root 0 Nov 20 15:15 other

$ node fstream-test.js 
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: EACCES, open '/tmp/stuff/other'