I have the following snippet of code that is in a function that gets called multiple times for different files.
var readStream = fs.createReadStream(file);
readStream.on('error', function(err) {
console.log(err);
});
Regularly, some files, but not all, will error with the following message:
OK, open '{filename}'
The exact number of errors isn't always the same, but it's roughly the same amount. And it's not always the same files. I am processing ~6500 files and get ~1150 errors.
What does this error mean? What am I doing wrong?
Take a look at graceful-fs. This is a node module which abstracts all the fs calls you wish to make with some addtionaly features. Especially useful in windows systems.
Usage is dead simple:
# Install
$ npm install graceful-fs
# Usage (in foo.js)
var fs = require('graceful-fs');