Closed
Description
We have some errors such as ERR_STREAM_WRITE_AFTER_END
, ERR_STREAM_DESTROYED
, ERR_STREAM_ALREADY_FINISHED
, ERR_INVALID_ARG_TYPE
etc. that are not due to internal stream errors but more along the line of external usage errors.
However, given current practice we always call errorOrDestroy
(or along similar lines) for all errors, even though these errors do not in any way bring the stream into erroneous state, e.g.
writable.end();
// Incorrect usage but the stream could still properly finish.
writable.write('moredata', err => {
console.log('usage error');
});
writable.on('error', err => {
console.log('internal error'):
});
I would like to propose that these kind of errors do not emit 'error'
nor destroy(err)
the instance, if a callback is provided in the method call that caused the error.
I believe this would make things easier in terms of what users expect while at the same time not swallowing errors per se.