Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Fix for Promise\settle() #50

Closed
wants to merge 3 commits into from
Closed

Fix for Promise\settle() #50

wants to merge 3 commits into from

Conversation

mxr576
Copy link

@mxr576 mxr576 commented May 25, 2018

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #49
Documentation -
License MIT

What's in this PR?

Possible fix for the issue described in #49.

Why?

Example Usage

Checklist

To Do

@mxr576
Copy link
Author

mxr576 commented May 25, 2018

Hm, maybe this actually going to be a BC breaking change? o.O

@Nyholm
Copy link
Member

Nyholm commented May 25, 2018

Thank you for this PR.

As far as I know, the wait function should return a response or an exception. Why do you think that should change?

@mxr576
Copy link
Author

mxr576 commented May 25, 2018

@Nyholm Please read #49 for more information about the reasons behind this PR. This is just a possible solution to this problem maybe this is not the best.

wait() can return promise as well, return value depends on the value of unwrap. Example from Guzzle Promises: https://github.com/guzzle/promises/blob/v1.3.1/src/Promise.php#L60

@Nyholm
Copy link
Member

Nyholm commented May 25, 2018

@Nyholm Please read #49 for more information about the reasons behind this PR. This is just a possible solution to this problem maybe this is not the best.

Okey, I had a quick look now.

As far as I know, the wait function should return a response or an exception.

It should return a "resolved" value: https://github.com/php-http/promise/blob/master/src/Promise.php#L64


I think this PR is a BC break. But I think agree with #49, but this might not be the perfect solution. I let people more knowledgeable than me continue to review this.

@mxr576
Copy link
Author

mxr576 commented May 25, 2018

Hint, probably there is a difference between how wait() is implemented in php-http/promise and guzzle/promise.

https://github.com/guzzle/promises/blob/v1.3.1/src/PromiseInterface.php#L92

@mxr576
Copy link
Author

mxr576 commented May 28, 2018

I am closing this PR, because this is clearly not the best solution for addressing this problem. I tried multiple things, but I could not fix this problem. It seems settle() won't work properly until wrapped promise has to be fulfilled in Promise::wrap() because https://github.com/guzzle/promises/blob/v1.3.1/src/Promise.php#L255.
A possible workaround could be disabling http_errors option in Guzzle client and manually transforming >= 400 HTTP codes to exceptions if needed.

@mxr576 mxr576 closed this May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Promise\settle() is not working properly
2 participants