stream.finished() leaves dangling event listeners (in particular
'error', 'end', 'finish' and 'close') after the returned promise is
resolved or rejected. The reason for this is so that unexpected 'error'
events (due to incorrect stream implementations) do not cause unexpected
crashes. If this is unwanted behavior then options.cleanup should be set to
true:
The
finishedAPI also provides a callback version.stream.finished()leaves dangling event listeners (in particular'error','end','finish'and'close') after the returned promise is resolved or rejected. The reason for this is so that unexpected'error'events (due to incorrect stream implementations) do not cause unexpected crashes. If this is unwanted behavior thenoptions.cleanupshould be set totrue: