Skip to content

Commit

Permalink
Handle empty responses from XHR due to fetching large response bodies…
Browse files Browse the repository at this point in the history
… with a better error message.

PiperOrigin-RevId: 679300061
  • Loading branch information
sufyanAbbasi authored and Google Earth Engine Authors committed Sep 26, 2024
1 parent 292f5d7 commit 4a27088
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions javascript/src/apiclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,11 @@ apiclient.handleResponse_ = function(
}
return {parsed: response};
} catch (e) {
if (body === '') {
// XHR returns an empty string for large responses.
return 'Response was too large to parse. ' +
'Hint: Try using limit() to fetch less elements of a collection.';
}
return 'Invalid JSON: ' + body;
}
};
Expand Down

0 comments on commit 4a27088

Please sign in to comment.