@sambath999/localize-token 12.4.4 → 12.4.5

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.
@@ -1035,15 +1035,6 @@
1035
1035
  ? normalizedUrl.slice(0, -1)
1036
1036
  : normalizedUrl;
1037
1037
  };
1038
- // normalizeError(error: HttpErrorResponse): INormalizedError {
1039
- // return {
1040
- // error: error.error || {},
1041
- // code: error.error?.code || `HTTP_${error.status}`,
1042
- // message: error.error?.message || error.message,
1043
- // details: error.error?.details,
1044
- // status: error.status
1045
- // };
1046
- // }
1047
1038
  LocalizeApiHelper.prototype.invokeHook = function (callback) {
1048
1039
  return __awaiter(this, void 0, void 0, function () {
1049
1040
  var result;
@@ -1277,12 +1268,12 @@
1277
1268
  case 0:
1278
1269
  if (error.status !== 401)
1279
1270
  throw error;
1280
- return [4 /*yield*/, waitUntil(function () { return !_this.isResolvingStartup; }, 500)];
1271
+ return [4 /*yield*/, waitUntil(function () { return !_this.isResolvingStartup; }, 50)];
1281
1272
  case 1:
1282
1273
  _e.sent();
1283
1274
  return [4 /*yield*/, ApiHelper.performRetry({
1284
1275
  maxRetries: function () { return 1000; },
1285
- delay: 500,
1276
+ delay: 10,
1286
1277
  retryUnless: function (error) { return error.status === 401 || ApiHelper.isConnectionError(error); },
1287
1278
  callback: function () { return __awaiter(_this, void 0, void 0, function () {
1288
1279
  return __generator(this, function (_e) {
@@ -1385,32 +1376,28 @@
1385
1376
  LocalizeApiService.prototype.toWaitForPreviousRequest = function () {
1386
1377
  var _a;
1387
1378
  return __awaiter(this, void 0, void 0, function () {
1388
- var _e, _f;
1379
+ var waitMilliseconds;
1389
1380
  var _this = this;
1390
- return __generator(this, function (_g) {
1391
- switch (_g.label) {
1381
+ return __generator(this, function (_e) {
1382
+ switch (_e.label) {
1392
1383
  case 0:
1393
- _e = this.isRevokingToken;
1394
- if (!_e) return [3 /*break*/, 2];
1384
+ if (!this.isRevokingToken) return [3 /*break*/, 2];
1385
+ // console.warn('A token refresh is in progress. Request is waiting.');
1395
1386
  return [4 /*yield*/, waitUntil(function () { return !_this.isRevokingToken; })];
1396
1387
  case 1:
1397
- _e = (_g.sent());
1398
- _g.label = 2;
1388
+ // console.warn('A token refresh is in progress. Request is waiting.');
1389
+ _e.sent();
1390
+ _e.label = 2;
1399
1391
  case 2:
1400
- _e;
1401
- // to wait for each request in 50ms, even if the request is not completed
1402
- _f = ((_a = this.config.waitEachRequest) === null || _a === void 0 ? void 0 : _a.milliseconds);
1403
- if (!_f)
1404
- // to wait for each request in 50ms, even if the request is not completed
1405
- return [3 /*break*/, 4];
1406
- return [4 /*yield*/, waitFor(this.config.waitEachRequest.milliseconds, this.isRequesting)];
1392
+ waitMilliseconds = (_a = this.config.waitEachRequest) === null || _a === void 0 ? void 0 : _a.milliseconds;
1393
+ if (!(waitMilliseconds && this.isRequesting)) return [3 /*break*/, 4];
1394
+ // console.warn(`Request throttling: Another request is in progress. Waiting for ${waitMilliseconds}ms.`);
1395
+ return [4 /*yield*/, waitFor(waitMilliseconds, this.isRequesting)];
1407
1396
  case 3:
1408
- _f = (_g.sent());
1409
- _g.label = 4;
1410
- case 4:
1411
- // to wait for each request in 50ms, even if the request is not completed
1412
- _f;
1413
- return [2 /*return*/];
1397
+ // console.warn(`Request throttling: Another request is in progress. Waiting for ${waitMilliseconds}ms.`);
1398
+ _e.sent();
1399
+ _e.label = 4;
1400
+ case 4: return [2 /*return*/];
1414
1401
  }
1415
1402
  });
1416
1403
  });