@aws-amplify/predictions 4.0.35 → 4.0.36

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [4.0.36](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/predictions@4.0.35...@aws-amplify/predictions@4.0.36) (2022-03-28)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/predictions
9
+
10
+
11
+
12
+
13
+
6
14
  ## [4.0.35](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/predictions@4.0.34...@aws-amplify/predictions@4.0.35) (2022-03-22)
7
15
 
8
16
  **Note:** Version bump only for package @aws-amplify/predictions
@@ -98022,6 +98022,10 @@ function isBlob(body) {
98022
98022
  return typeof Blob !== 'undefined' && body instanceof Blob;
98023
98023
  }
98024
98024
 
98025
+ function hasErrorResponse(error) {
98026
+ return typeof error !== 'undefined' && Object.prototype.hasOwnProperty.call(error, 'response') && typeof error.response !== 'undefined' && Object.prototype.hasOwnProperty.call(error.response, 'status') && typeof error.response.status === 'number';
98027
+ }
98028
+
98025
98029
  var normalizeHeaders = function normalizeHeaders(headers, normalizedName) {
98026
98030
  var e_1, _a;
98027
98031
 
@@ -98165,16 +98169,20 @@ function () {
98165
98169
  })
98166
98170
  };
98167
98171
  })["catch"](function (error) {
98168
- var _a, _b, _c; // Error
98172
+ var _a, _b; // Error
98169
98173
 
98170
98174
 
98171
98175
  if (error.message !== _common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_4__["AWSS3ProviderUploadErrorStrings"].UPLOAD_PAUSED_MESSAGE) {
98172
98176
  logger.error(error.message);
98173
98177
  } // for axios' cancel error, we should re-throw it back so it's not considered an s3client error
98174
- // if we return empty, or an abitrary error HttpResponse, it will be hard to debug down the line
98178
+ // if we return empty, or an abitrary error HttpResponse, it will be hard to debug down the line.
98179
+ //
98180
+ // for errors that does not have a 'response' object, it's very likely that it is an unexpected error for
98181
+ // example a disconnect. Without it we cannot meaningfully reconstruct a HttpResponse, and the AWS SDK might
98182
+ // consider the request successful by mistake. In this case we should also re-throw the error.
98175
98183
 
98176
98184
 
98177
- if (axios__WEBPACK_IMPORTED_MODULE_2___default.a.isCancel(error)) {
98185
+ if (axios__WEBPACK_IMPORTED_MODULE_2___default.a.isCancel(error) || !hasErrorResponse(error)) {
98178
98186
  throw error;
98179
98187
  } // otherwise, we should re-construct an HttpResponse from the error, so that it can be passed down to other
98180
98188
  // aws sdk middleware (e.g retry, clock skew correction, error message serializing)
@@ -98182,9 +98190,9 @@ function () {
98182
98190
 
98183
98191
  return {
98184
98192
  response: new _aws_sdk_protocol_http__WEBPACK_IMPORTED_MODULE_0__["HttpResponse"]({
98185
- statusCode: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
98186
- body: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
98187
- headers: (_c = error.response) === null || _c === void 0 ? void 0 : _c.headers
98193
+ statusCode: error.response.status,
98194
+ body: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
98195
+ headers: (_b = error.response) === null || _b === void 0 ? void 0 : _b.headers
98188
98196
  })
98189
98197
  };
98190
98198
  }), requestTimeout(requestTimeoutInMs)];