-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid hidding exceptions thrown in HttpClient\Request error handlers #31
Conversation
Thanks for spotting! These could certainly introduce some subtle and hard to trace issues. Afaict you're trying to throw an Can you provide a simple gist that exhibits this? |
Hi @clue,
I guess the request/response shouldn't be considered to be in a consistent state after that :) But at least, the exception should be allowed to unwind and eventually trigger a visible error if not caught by user code.
I'm guilty, I didn't planned for that when I wrote reactphp/http-client :)
Sure ! Here it is: https://gist.github.com/arnaud-lb/71cf44ab2564b810b463 As you can see, I'm not throwing an exception myself. (And at first, one wouldn't think that the exception is thrown in the error event handler; but it is.) However, I'm expecting to at least see exceptions that are thrown. The problem disappears after merging both reactphp/dns#26 and #31. Thanks! |
Going to review and test this tonight and get back to it here, thanks for spotting 👍 |
LGTM 👍 , @clue do you want to check, merge and tag reactphp/dns#26 first before signing this one off or should I go ahead and merge and tag this one first? |
Thanks for the background @arnaud-lb! LGTM 👍 @WyriHaximus both PRs LGTM, so feel free to review the other one and push either one forward 👍 |
Ping @arnaud-lb, can you update this to require Otherwise LGTM 👍 |
LGTM 👍 |
Required promise ~2.2
Avoid hidding exceptions thrown in HttpClient\Request error handlers
then()
catches exceptions, which is not desirable when its result is not returned.The following code throws an exception in the 'error' event handler. However, the exception is caught because the event is fired in a
then()
callback.This PR fixes this by changing a
then
to adone
.Actual use case: