Fetch
Fetch copied to clipboard
Replace Async functionality
PHP.Gt/Async and PHP.Gt/Promise will reduce the dependency complexity.
Currently the 1st "basic usage" example works fully, but if it's forced to decode JSON with a syntax error the promise rejection is eaten up silently... investigating next.
This is harder than I thought it would be.
The entire codebase is greatly improved and tidy now, with more type safety, but this issue still remains as the only known bug.
https://github.com/PhpGt/Fetch/blob/144cedb2070c91f32b301a3bdcc8dbdf4fc4ad97/src/Response/BodyResponse.php#L113-L131
This is where the issue lies, in the resolution of the JSON data. If the JSON data is invalid, like it is when used in example/01-basic-fetch.php
, the exception is thrown rather than passed up the promise chain.
It's actually not a breaking issue, because it only represents internal failures (things like curl exceptions, timeouts or when $response->ok fails, are all still caught correctly). It might make sense to release the code in its currently improved state, then track this issue in a separate issue to return to later.