Skip to content
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

Apply Onyx failureData on fetch failure #27650

Merged
merged 12 commits into from
Oct 4, 2023
9 changes: 2 additions & 7 deletions src/libs/Middleware/SaveResponseInOnyx.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@ const requestsToIgnoreLastUpdateID = ['OpenApp', 'ReconnectApp', 'GetMissingOnyx
* @returns {Promise}
*/
function SaveResponseInOnyx(requestResponse, request) {
return requestResponse
.then((response) => {
// Make sure we have response data (i.e. response isn't a promise being passed down to us by a failed retry request and response undefined)
if (!response) {
return;
}
const onyxUpdates = response.onyxData;
return requestResponse.then((response = {}) => {
const onyxUpdates = response.onyxData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's case of response = null, which will make crash on this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't come across that case yet since I've only seen response = undefined or an actual response object. I could add the null check back if we think it's valuable


// Sometimes we call requests that are successfull but they don't have any response or any success/failure data to set. Let's return early since
// we don't need to store anything here.
Expand Down
Loading