Closed

Description
I'm on a mac, Node v8.6.0.
Briefly, if I do this in mocha :
import fs from 'fs-extra'
const stream = fse.createWriteStream(
path.normalize('./myfile.txt'),
{flags: 'a', encoding: 'utf8', mode: 0o0666}
)
stream.on('error', err => {
// this is never called
console.log(err)
})
fs.unlinkSync('./myfile.txt')
try{
stream.write('whatever', () => {
console.log('All is well.')
})
}
catch (err) {
assert.isUndefined(err)
}
const stream = fse.createWriteStream(
path.normalize('./myfile.txt'),
{flags: 'a', encoding: UTF8, mode: FILE_MODE}
)
stream.on('error', err => {
assert.isNotOk(err)
})
// !!! I delete the stream`s file
fs.unlinkSync('./myfile.txt')
try{
stream.write('whatever')
}
catch (err) {
assert.isUndefined(err)
}
the test passes.
I don't thimk this has anything to do with importing fs-extra. It's just a wrapper for fs.
Is this a normal behaviour? Shouldn't there be some way to prevent this kind of error?
Thank you for your time.