@hatchet-dev/typescript-sdk 0.15.1-alpha1 → 0.15.1-alpha3

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.
@@ -93,7 +93,7 @@ class EventClient {
93
93
  });
94
94
  }), this.logger).catch((e) => {
95
95
  // log a warning, but this is not a fatal error
96
- this.logger.warn(`Could not put log: ${e.message}`);
96
+ this.logger.warn(`Could not put log: ${e.message.substring(0, 100)}`);
97
97
  });
98
98
  }
99
99
  putStream(stepRunId, data) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.15.1-alpha1",
3
+ "version": "0.15.1-alpha3",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/util/retrier.js CHANGED
@@ -14,8 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.retrier = retrier;
16
16
  const sleep_1 = __importDefault(require("./sleep"));
17
- const DEFAULT_RETRY_INTERVAL = 5; // seconds
18
- const DEFAULT_RETRY_COUNT = 5;
17
+ const DEFAULT_RETRY_INTERVAL = 0.1; // seconds
18
+ const DEFAULT_RETRY_COUNT = 8;
19
+ const MAX_JITTER = 400; // milliseconds
19
20
  function retrier(fn_1, logger_1) {
20
21
  return __awaiter(this, arguments, void 0, function* (fn, logger, retries = DEFAULT_RETRY_COUNT, interval = DEFAULT_RETRY_INTERVAL) {
21
22
  let lastError;
@@ -27,7 +28,11 @@ function retrier(fn_1, logger_1) {
27
28
  catch (e) {
28
29
  lastError = e;
29
30
  logger.error(`Error: ${e.message}`);
30
- yield (0, sleep_1.default)(interval * 1000);
31
+ // Calculate exponential backoff with random jitter
32
+ const exponentialDelay = interval * 2 ** i * 1000;
33
+ const jitter = Math.random() * MAX_JITTER;
34
+ const totalDelay = exponentialDelay + jitter;
35
+ yield (0, sleep_1.default)(totalDelay);
31
36
  }
32
37
  }
33
38
  throw lastError;