#39314 closed defect (bug) (fixed)
WP-API Backbone Client: buildModelGetter fails to reject deferred on fetch error
Reported by: | westonruter | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | 4.7.1 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | REST API | Keywords: | has-patch has-unit-tests commit |
Focuses: | Cc: |
Description
I found an issue where the promise returned by getAuthorUser
never resolves in the case of a request error (such as a 404). I found that the client is only accounting for the success case in which the deferred is resolved, but it is not accounting for the error case in which the deferred is just left pending.
Attachments (3)
Change History (15)
#1
@
8 years ago
- Keywords has-patch added
- Owner set to adamsilverstein
- Status changed from new to assigned
- Version set to 4.7
#2
@
8 years ago
I went ahead and opened a PR: https://github.com/WP-API/client-js/pull/149
#3
@
8 years ago
- Keywords has-unit-tests commit added
Thanks @westonruter - good catch! I went ahead and added an error handler for the other get helper builder and a unit test to confirm the behavior for getAuthorUser
in https://github.com/WP-API/client-js/pull/150 (diff). Ultimately I would like to expand the unit test to cover all helpers. I confirmed the test I wrote fails before your patch and passes after it. I will add the test to my patch on #39264 when I get these tests into core.
#4
@
8 years ago
In 39314.diff :
Ensure that when a helper method's underlying fetch call fails, reject gets called on the promise returned by the helper method. Enables better error handling.
#5
@
8 years ago
@westonruter can you please give 39314.diff a review/commit?
#6
@
8 years ago
@adamsilverstein What do you want to do here? If @westonruter doesn't have the bandwidth to review, is there someone else? Or do you want to punt this to 4.7.2?
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#8
@
8 years ago
@rachelbaker I can commit to trunk, I think I need a review from a permanent committer to merge to 4.7.1
#10
@
8 years ago
@adamsilverstein Patch looks good. I just trimmed some extra line breaks in 39314.2.diff for a cleaner diff.
@adamsilverstein I made this 39314.0.diff patch off of
wp-api.js
, though I know it's a compiled file. I know you'll know how to apply it.Also, any other cases of
fetch
being done in the Backbone client should also ensure that there is a rejection of the deferred in the case of an error as seen in this patch.