@google/earthengine 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/earthengine",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "JavaScript client for Google Earth Engine API.",
5
5
  "author": "Google LLC",
6
6
  "license": "Apache-2.0",
package/src/apiclient.js CHANGED
@@ -24,7 +24,7 @@ const {trustedResourceUrl} = goog.require('safevalues');
24
24
  /** @namespace */
25
25
  const apiclient = {};
26
26
 
27
- const API_CLIENT_VERSION = '1.1.2';
27
+ const API_CLIENT_VERSION = '1.1.4';
28
28
 
29
29
  exports.VERSION = apiVersion.VERSION;
30
30
  exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
@@ -1058,6 +1058,11 @@ apiclient.handleResponse_ = function(
1058
1058
  }
1059
1059
  return {parsed: response};
1060
1060
  } catch (e) {
1061
+ if (body === '') {
1062
+ // XHR returns an empty string for large responses (>100 MB) or when
1063
+ // there is a network error. Handle this case in the caller.
1064
+ return '';
1065
+ }
1061
1066
  return 'Invalid JSON: ' + body;
1062
1067
  }
1063
1068
  };
@@ -1068,6 +1073,8 @@ apiclient.handleResponse_ = function(
1068
1073
  } else if (status < 200 || status >= 300) {
1069
1074
  return 'Server returned HTTP code: ' + status + ' for ' + method + ' ' +
1070
1075
  url;
1076
+ } else {
1077
+ return '';
1071
1078
  }
1072
1079
  };
1073
1080
 
@@ -1079,7 +1086,11 @@ apiclient.handleResponse_ = function(
1079
1086
  if (response.parsed) {
1080
1087
  data = response.parsed;
1081
1088
  } else {
1082
- errorMessage = response;
1089
+ // Empty response bodies are handled here: return the status error if
1090
+ // there is one, otherwise the long response error.
1091
+ const responseTooLargeMessage = 'Response was too large to parse. ' +
1092
+ 'Hint: Use limit() to fetch less elements of a collection.';
1093
+ errorMessage = response || statusError(status) || responseTooLargeMessage;
1083
1094
  }
1084
1095
  } else if (contentType === 'multipart/mixed') {
1085
1096
  data = {};