stream: ensure writable.destroy() emits error once
Prevent the 'error'
event from being emitted multiple times if
writable.destroy()
is called with an error before the _destroy()
callback is called.
Emit the first error, discard all others.
Fixes: https://github.com/nodejs/node/issues/26015 Refs: https://github.com/nodejs/node/pull/20745#discussion_r191537229
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines