Fetch icon indicating copy to clipboard operation
Fetch copied to clipboard

Replace Async functionality

Open g105b opened this issue 4 years ago • 1 comments

PHP.Gt/Async and PHP.Gt/Promise will reduce the dependency complexity.

g105b avatar Dec 29 '20 21:12 g105b

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.

g105b avatar Sep 14 '22 15:09 g105b

This is harder than I thought it would be.

g105b avatar Jan 17 '23 16:01 g105b

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.

g105b avatar Jan 19 '23 23:01 g105b