@aws-amplify/storage 4.4.18 → 4.4.19

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,17 @@
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.4.19](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.4.18...@aws-amplify/storage@4.4.19) (2022-03-28)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **storage:** axios handler error handling fix ([#9587](https://github.com/aws-amplify/amplify-js/issues/9587)) ([2ceaa44](https://github.com/aws-amplify/amplify-js/commit/2ceaa44ce88c96e9121b903c0d9798e4a918df4a))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [4.4.18](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/storage@4.4.17...@aws-amplify/storage@4.4.18) (2022-03-22)
7
18
 
8
19
  **Note:** Version bump only for package @aws-amplify/storage
@@ -51050,6 +51050,10 @@ function isBlob(body) {
51050
51050
  return typeof Blob !== 'undefined' && body instanceof Blob;
51051
51051
  }
51052
51052
 
51053
+ function hasErrorResponse(error) {
51054
+ 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';
51055
+ }
51056
+
51053
51057
  var normalizeHeaders = function normalizeHeaders(headers, normalizedName) {
51054
51058
  var e_1, _a;
51055
51059
 
@@ -51193,16 +51197,20 @@ function () {
51193
51197
  })
51194
51198
  };
51195
51199
  })["catch"](function (error) {
51196
- var _a, _b, _c; // Error
51200
+ var _a, _b; // Error
51197
51201
 
51198
51202
 
51199
51203
  if (error.message !== _common_StorageErrorStrings__WEBPACK_IMPORTED_MODULE_4__["AWSS3ProviderUploadErrorStrings"].UPLOAD_PAUSED_MESSAGE) {
51200
51204
  logger.error(error.message);
51201
51205
  } // for axios' cancel error, we should re-throw it back so it's not considered an s3client error
51202
- // if we return empty, or an abitrary error HttpResponse, it will be hard to debug down the line
51206
+ // if we return empty, or an abitrary error HttpResponse, it will be hard to debug down the line.
51207
+ //
51208
+ // for errors that does not have a 'response' object, it's very likely that it is an unexpected error for
51209
+ // example a disconnect. Without it we cannot meaningfully reconstruct a HttpResponse, and the AWS SDK might
51210
+ // consider the request successful by mistake. In this case we should also re-throw the error.
51203
51211
 
51204
51212
 
51205
- if (axios__WEBPACK_IMPORTED_MODULE_2___default.a.isCancel(error)) {
51213
+ if (axios__WEBPACK_IMPORTED_MODULE_2___default.a.isCancel(error) || !hasErrorResponse(error)) {
51206
51214
  throw error;
51207
51215
  } // otherwise, we should re-construct an HttpResponse from the error, so that it can be passed down to other
51208
51216
  // aws sdk middleware (e.g retry, clock skew correction, error message serializing)
@@ -51210,9 +51218,9 @@ function () {
51210
51218
 
51211
51219
  return {
51212
51220
  response: new _aws_sdk_protocol_http__WEBPACK_IMPORTED_MODULE_0__["HttpResponse"]({
51213
- statusCode: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
51214
- body: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
51215
- headers: (_c = error.response) === null || _c === void 0 ? void 0 : _c.headers
51221
+ statusCode: error.response.status,
51222
+ body: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
51223
+ headers: (_b = error.response) === null || _b === void 0 ? void 0 : _b.headers
51216
51224
  })
51217
51225
  };
51218
51226
  }), requestTimeout(requestTimeoutInMs)];