On Windows if I create a file and add the read-only attribute, and then make this call:
console.log('a');
let fileWriteStream = fs.createWriteStream('D:\\read-only-file.txt');
console.log('b');
console.log('c');
I see this in the Chrome console:
a
b
Uncaught Error: EPERM: operation not permitted, open 'D:\read-only-file.txt'
c
But is there a way to actually catch this error? If I go on to try and use the file write stream anyway (i.e. pipe with http) it doesn't actually do anything. If I add this handler:
fileWriteStream.on('error', function (err) {
console.log('in error...');
});
The error handler is not called. It is like this read-only exception is internally orphaned. Is there a way to handle this failure?
Thanks