re-raise error if error occurs before committing in streaming

update the tests, using an if-else
Merge pull request #14090 from Fortisque/kevin/stream_error_in_main_thread_if_not_committed

re-raise error if error occurs before committing in streaming