@aws-amplify/datastore 3.7.9-unstable.1 → 3.7.9

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
+ ## [3.7.9](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.7.8...@aws-amplify/datastore@3.7.9) (2022-03-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **@aws-amplify/datastore:** fix mutations to retry indefinitely on network error ([#9724](https://github.com/aws-amplify/amplify-js/issues/9724)) ([5371380](https://github.com/aws-amplify/amplify-js/commit/53713804b79df9c69ac29b75ffc576b4c2002507))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [3.7.8](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.7.7...@aws-amplify/datastore@3.7.8) (2022-03-10)
7
18
 
8
19
  **Note:** Version bump only for package @aws-amplify/datastore
@@ -73481,13 +73481,14 @@ function () {
73481
73481
  /*!*************************************!*\
73482
73482
  !*** ../core/lib-esm/Util/Retry.js ***!
73483
73483
  \*************************************/
73484
- /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry */
73484
+ /*! exports provided: NonRetryableError, retry, jitteredBackoff, jitteredExponentialRetry */
73485
73485
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73486
73486
 
73487
73487
  "use strict";
73488
73488
  __webpack_require__.r(__webpack_exports__);
73489
73489
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NonRetryableError", function() { return NonRetryableError; });
73490
73490
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "retry", function() { return retry; });
73491
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jitteredBackoff", function() { return jitteredBackoff; });
73491
73492
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jitteredExponentialRetry", function() { return jitteredExponentialRetry; });
73492
73493
  /* harmony import */ var _Logger_ConsoleLogger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Logger/ConsoleLogger */ "../core/lib-esm/Logger/ConsoleLogger.js");
73493
73494
  var __extends = undefined && undefined.__extends || function () {
@@ -73802,8 +73803,16 @@ function retry(functionToRetry, args, delayFn, attempt) {
73802
73803
  });
73803
73804
  }
73804
73805
  var MAX_DELAY_MS = 5 * 60 * 1000;
73806
+ /**
73807
+ * @private
73808
+ * Internal use of Amplify only
73809
+ */
73805
73810
 
73806
73811
  function jitteredBackoff(maxDelayMs) {
73812
+ if (maxDelayMs === void 0) {
73813
+ maxDelayMs = MAX_DELAY_MS;
73814
+ }
73815
+
73807
73816
  var BASE_TIME_MS = 100;
73808
73817
  var JITTER_FACTOR = 100;
73809
73818
  return function (attempt) {
@@ -73816,7 +73825,6 @@ function jitteredBackoff(maxDelayMs) {
73816
73825
  * Internal use of Amplify only
73817
73826
  */
73818
73827
 
73819
-
73820
73828
  var jitteredExponentialRetry = function jitteredExponentialRetry(functionToRetry, args, maxDelayMs) {
73821
73829
  if (maxDelayMs === void 0) {
73822
73830
  maxDelayMs = MAX_DELAY_MS;
@@ -73855,7 +73863,7 @@ function urlSafeDecode(hex) {
73855
73863
  /*!*************************************!*\
73856
73864
  !*** ../core/lib-esm/Util/index.js ***!
73857
73865
  \*************************************/
73858
- /*! exports provided: NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES */
73866
+ /*! exports provided: NonRetryableError, retry, jitteredBackoff, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES */
73859
73867
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73860
73868
 
73861
73869
  "use strict";
@@ -73865,6 +73873,8 @@ __webpack_require__.r(__webpack_exports__);
73865
73873
 
73866
73874
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "retry", function() { return _Retry__WEBPACK_IMPORTED_MODULE_0__["retry"]; });
73867
73875
 
73876
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredBackoff", function() { return _Retry__WEBPACK_IMPORTED_MODULE_0__["jitteredBackoff"]; });
73877
+
73868
73878
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredExponentialRetry", function() { return _Retry__WEBPACK_IMPORTED_MODULE_0__["jitteredExponentialRetry"]; });
73869
73879
 
73870
73880
  /* harmony import */ var _Mutex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Mutex */ "../core/lib-esm/Util/Mutex.js");
@@ -73945,7 +73955,7 @@ var USER_AGENT_HEADER = 'x-amz-user-agent';
73945
73955
  /*!********************************!*\
73946
73956
  !*** ../core/lib-esm/index.js ***!
73947
73957
  \********************************/
73948
- /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, Amplify, default */
73958
+ /*! exports provided: AmplifyClass, ClientDevice, ConsoleLogger, Logger, missingConfig, invalidParameter, Hub, I18n, isEmpty, sortByField, objectLessAttributes, filenameToContentType, isTextFile, generateRandomString, makeQuerablePromise, isWebWorker, browserOrNode, transferKeyToLowerCase, transferKeyToUpperCase, isStrictObject, JS, Signer, parseMobileHubConfig, Parser, AWSCloudWatchProvider, FacebookOAuth, GoogleOAuth, Linking, AppState, AsyncStorage, Credentials, CredentialsClass, ServiceWorker, StorageHelper, MemoryStorage, UniversalStorage, Platform, getAmplifyUserAgent, INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER, INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER, USER_AGENT_HEADER, Constants, NonRetryableError, retry, jitteredBackoff, jitteredExponentialRetry, Mutex, Reachability, DateUtils, urlSafeEncode, urlSafeDecode, AWS_CLOUDWATCH_BASE_BUFFER_SIZE, AWS_CLOUDWATCH_CATEGORY, AWS_CLOUDWATCH_MAX_BATCH_EVENT_SIZE, AWS_CLOUDWATCH_MAX_EVENT_SIZE, AWS_CLOUDWATCH_PROVIDER_NAME, NO_CREDS_ERROR_STRING, RETRY_ERROR_CODES, Amplify, default */
73949
73959
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
73950
73960
 
73951
73961
  "use strict";
@@ -74058,6 +74068,8 @@ __webpack_require__.r(__webpack_exports__);
74058
74068
 
74059
74069
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "retry", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["retry"]; });
74060
74070
 
74071
+ /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredBackoff", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["jitteredBackoff"]; });
74072
+
74061
74073
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "jitteredExponentialRetry", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["jitteredExponentialRetry"]; });
74062
74074
 
74063
74075
  /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mutex", function() { return _Util__WEBPACK_IMPORTED_MODULE_18__["Mutex"]; });
@@ -92137,11 +92149,12 @@ function () {
92137
92149
  /*!*********************************************!*\
92138
92150
  !*** ./lib-esm/sync/processors/mutation.js ***!
92139
92151
  \*********************************************/
92140
- /*! exports provided: MutationProcessor */
92152
+ /*! exports provided: safeJitteredBackoff, MutationProcessor */
92141
92153
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
92142
92154
 
92143
92155
  "use strict";
92144
92156
  __webpack_require__.r(__webpack_exports__);
92157
+ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "safeJitteredBackoff", function() { return safeJitteredBackoff; });
92145
92158
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MutationProcessor", function() { return MutationProcessor; });
92146
92159
  /* harmony import */ var _aws_amplify_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @aws-amplify/api */ "../api/lib-esm/index.js");
92147
92160
  /* harmony import */ var _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @aws-amplify/core */ "../core/lib-esm/index.js");
@@ -92695,7 +92708,7 @@ function () {
92695
92708
  case 0:
92696
92709
  return [4
92697
92710
  /*yield*/
92698
- , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["jitteredExponentialRetry"])(function (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) {
92711
+ , Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["retry"])(function (model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent) {
92699
92712
  return __awaiter(_this, void 0, void 0, function () {
92700
92713
  var _a, query, variables, graphQLCondition, opName, modelDefinition, authToken, tryWith, attempt, opType, result, err_1, _b, error, _c, _d, code, retryWith, err_2, _e, _f, opName_1, query_1, authToken_1, serverData, namespace, updatedMutation, err_3;
92701
92714
 
@@ -92900,7 +92913,7 @@ function () {
92900
92913
  }
92901
92914
  });
92902
92915
  });
92903
- }, [model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent])];
92916
+ }, [model, operation, data, condition, modelConstructor, MutationEvent, mutationEvent], safeJitteredBackoff)];
92904
92917
 
92905
92918
  case 1:
92906
92919
  return [2
@@ -93042,6 +93055,33 @@ function () {
93042
93055
  return MutationProcessor;
93043
93056
  }();
93044
93057
 
93058
+ var MAX_RETRY_DELAY_MS = 5 * 60 * 1000;
93059
+ var originalJitteredBackoff = Object(_aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["jitteredBackoff"])(MAX_RETRY_DELAY_MS);
93060
+ /**
93061
+ * @private
93062
+ * Internal use of Amplify only.
93063
+ *
93064
+ * Wraps the jittered backoff calculation to retry Network Errors indefinitely.
93065
+ * Backs off according to original jittered retry logic until the original retry
93066
+ * logic hits its max. After this occurs, if the error is a Network Error, we
93067
+ * ignore the attempt count and return MAX_RETRY_DELAY_MS to retry forever (until
93068
+ * the request succeeds).
93069
+ *
93070
+ * @param attempt ignored
93071
+ * @param _args ignored
93072
+ * @param error tested to see if `.message` is 'Network Error'
93073
+ * @returns number | false :
93074
+ */
93075
+
93076
+ var safeJitteredBackoff = function safeJitteredBackoff(attempt, _args, error) {
93077
+ var attemptResult = originalJitteredBackoff(attempt); // If this is the last attempt and it is a network error, we retry indefinitively every 5 minutes
93078
+
93079
+ if (attemptResult === false && (error === null || error === void 0 ? void 0 : error.message) === 'Network Error') {
93080
+ return MAX_RETRY_DELAY_MS;
93081
+ }
93082
+
93083
+ return attemptResult;
93084
+ };
93045
93085
 
93046
93086
 
93047
93087
  /***/ }),