stream: unpipe on destroy
Avoid writing to destination if it has been destroyed. 'close' is emitted asynchronously which can cause another read & write to be performed after destroy() causing a write after destroy error.
Adds a new event 'destroy'
to make this possible.
Fixes: https://github.com/nodejs/node/issues/29790
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines