stream: always emit error before close
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
Extracted from #19828. Fixes an issue from my error-handling pr, #18438 where a stream emits close
before error
on destroy. It should be error
before close
.