stream: fix finished w/ 'close' before 'end'
Emitting 'close' before 'end' on a Readable should result in a premature close error.
This is related to the one that caused trouble in https://github.com/nodejs/node/issues/29699. Includes the fix proposed in https://github.com/nodejs/node/pull/29724.
Related discussion: https://github.com/nodejs/node/pull/29724/files#r329128356
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