reqwest-eventsource icon indicating copy to clipboard operation
reqwest-eventsource copied to clipboard

What error conditions should be handled?

Open huntc opened this issue 1 year ago • 3 comments

Thanks for providing this project.

I'm curious as to what causes an error to occur when consuming the event source stream and what must therefore should be handled by the application. I've found that browsers handle some errors and retry, but if you get a bad gateway response then the event source errors with them. Is there similar behaviour here?

huntc avatar Feb 14 '24 06:02 huntc

A quick experiment yielded the following having terminated the server end:

request or response body error: error reading a body from connection: unexpected EOF during chunk size line

My expectation is that this library would retry given the default retry policy.

huntc avatar Feb 14 '24 06:02 huntc

It has become clear to me now that one does not es.close() given a streaming error. Instead, the event source will retry. I think the example would benefit from avoiding the closing of the event source given the inherent and familiar behaviour of retries.

huntc avatar Feb 14 '24 22:02 huntc

Happy to provide a PR on the example if there is agreement.

huntc avatar Feb 14 '24 22:02 huntc