A lot of modules, both internal (fs, net, http) and external (through2 and others) implement stream.destroy() and in fact I alway recommend using @mafintosh's pump to pipe streams. That module automatically calls destroy() if present, so no file descriptors are leaked in case of an error.
Given that it is a de-facto standard, we can document it in the stream API, and add a default implementation of it.
Maybe we can even go further and add a pump-equivalent in core, maybe as an option to pipe.
cc @nodejs/streams
A lot of modules, both internal (fs, net, http) and external (through2 and others) implement
stream.destroy()and in fact I alway recommend using @mafintosh's pump to pipe streams. That module automatically callsdestroy()if present, so no file descriptors are leaked in case of an error.Given that it is a de-facto standard, we can document it in the stream API, and add a default implementation of it.
Maybe we can even go further and add a pump-equivalent in core, maybe as an option to pipe.
cc @nodejs/streams