@camunda8/orchestration-cluster-api 10.0.0-alpha.24 → 10.0.0-alpha.25

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
@@ -1,3 +1,10 @@
1
+ # [10.0.0-alpha.25](https://github.com/camunda/orchestration-cluster-api-js/compare/v10.0.0-alpha.24...v10.0.0-alpha.25) (2026-08-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **runtime:** back off job-worker activation retries on transport errors ([#411](https://github.com/camunda/orchestration-cluster-api-js/issues/411)) ([bccaabe](https://github.com/camunda/orchestration-cluster-api-js/commit/bccaabeffc995b30fcb83488538928e57c8de953))
7
+
1
8
  # [10.0.0-alpha.24](https://github.com/camunda/orchestration-cluster-api-js/compare/v10.0.0-alpha.23...v10.0.0-alpha.24) (2026-08-04)
2
9
 
3
10
 
@@ -317,6 +317,33 @@ function createVariableSearchFetchPage(params) {
317
317
  };
318
318
  }
319
319
 
320
+ // src/runtime/pollBackoff.ts
321
+ var DEFAULT_POLL_BACKOFF_MIN_MS = 1e3;
322
+ var DEFAULT_POLL_BACKOFF_MAX_MS = 3e4;
323
+ var MAX_SAFE_TIMEOUT_MS = 2147483647;
324
+ function computePollBackoffMs(attempt, opts) {
325
+ const rng = opts.rng ?? Math.random;
326
+ const min = Number.isFinite(opts.minMs) ? Math.min(MAX_SAFE_TIMEOUT_MS, Math.max(0, Math.floor(opts.minMs))) : 0;
327
+ const max = Number.isFinite(opts.maxMs) ? Math.min(MAX_SAFE_TIMEOUT_MS, Math.max(min, Math.floor(opts.maxMs))) : min;
328
+ const safeAttempt = Number.isFinite(attempt) ? Math.max(1, Math.floor(attempt)) : 1;
329
+ const exponent = Math.min(safeAttempt - 1, 53);
330
+ const cap = Math.min(max, min * 2 ** exponent);
331
+ const half = cap / 2;
332
+ const r = rng();
333
+ const jitter = Number.isFinite(r) ? Math.min(1, Math.max(0, r)) : 0;
334
+ return Math.round(half + jitter * half);
335
+ }
336
+ function nextActivationRetryDelayMs(attempt, cfg, rng) {
337
+ if (cfg.pollBackoffMinMs > 0) {
338
+ return computePollBackoffMs(attempt, {
339
+ minMs: cfg.pollBackoffMinMs,
340
+ maxMs: cfg.pollBackoffMaxMs,
341
+ rng
342
+ });
343
+ }
344
+ return Number.isFinite(cfg.pollIntervalMs) ? Math.max(0, Math.round(cfg.pollIntervalMs)) : 0;
345
+ }
346
+
320
347
  // src/runtime/workerStartGate.ts
321
348
  var WorkerStartGate = class {
322
349
  /**
@@ -376,6 +403,8 @@ var JobWorker = class {
376
403
  _pollTimer = null;
377
404
  _inFlightActivation = null;
378
405
  // CancelablePromise-like
406
+ /** Consecutive failed activation requests; drives the retry backoff, reset on success. */
407
+ _consecutiveActivationErrors = 0;
379
408
  _log;
380
409
  _startGate;
381
410
  constructor(client2, cfg) {
@@ -383,6 +412,8 @@ var JobWorker = class {
383
412
  this._cfg = {
384
413
  ...cfg,
385
414
  pollIntervalMs: cfg.pollIntervalMs ?? 1,
415
+ pollBackoffMinMs: cfg.pollBackoffMinMs ?? DEFAULT_POLL_BACKOFF_MIN_MS,
416
+ pollBackoffMaxMs: cfg.pollBackoffMaxMs ?? DEFAULT_POLL_BACKOFF_MAX_MS,
386
417
  autoStart: cfg.autoStart ?? true,
387
418
  validateSchemas: cfg.validateSchemas ?? false,
388
419
  maxParallelJobs: cfg.maxParallelJobs ?? 10,
@@ -527,6 +558,7 @@ var JobWorker = class {
527
558
  this._inFlightActivation = this._client.activateJobs(body);
528
559
  const activation = await this._inFlightActivation;
529
560
  this._inFlightActivation = null;
561
+ this._consecutiveActivationErrors = 0;
530
562
  result = activation?.jobs || [];
531
563
  this._log.debug(() => ["activation.response", { jobs: result.length }]);
532
564
  } catch (e) {
@@ -534,10 +566,17 @@ var JobWorker = class {
534
566
  if (this._stopped) return;
535
567
  if (e?.name === "CancelSdkError") {
536
568
  this._log.debug("activation.cancelled");
537
- } else {
538
- this._log.error("activation.error", e);
569
+ this._scheduleNext(this._cfg.pollIntervalMs);
570
+ return;
539
571
  }
540
- this._scheduleNext(this._cfg.pollIntervalMs);
572
+ this._consecutiveActivationErrors += 1;
573
+ const delayMs = nextActivationRetryDelayMs(this._consecutiveActivationErrors, this._cfg);
574
+ this._log.error("activation.error", e);
575
+ this._log.debug(() => [
576
+ "activation.retry",
577
+ { attempt: this._consecutiveActivationErrors, retryInMs: delayMs }
578
+ ]);
579
+ this._scheduleNext(delayMs);
541
580
  return;
542
581
  }
543
582
  if (!result || result.length === 0) {
@@ -4849,7 +4888,7 @@ function installAuthInterceptor(client2, getStrategy, getAuthHeaders) {
4849
4888
  }
4850
4889
 
4851
4890
  // src/runtime/version.ts
4852
- var packageVersion = "10.0.0-alpha.24";
4891
+ var packageVersion = "10.0.0-alpha.25";
4853
4892
 
4854
4893
  // src/runtime/supportLogger.ts
4855
4894
  var NoopSupportLogger = class {
@@ -5954,6 +5993,8 @@ var ThreadedJobWorker = class {
5954
5993
  _stopped = false;
5955
5994
  _pollTimer = null;
5956
5995
  _inFlightActivation = null;
5996
+ /** Consecutive failed activation requests; drives the retry backoff, reset on success. */
5997
+ _consecutiveActivationErrors = 0;
5957
5998
  _log;
5958
5999
  _jobQueue = [];
5959
6000
  _startGate;
@@ -5963,6 +6004,8 @@ var ThreadedJobWorker = class {
5963
6004
  this._cfg = {
5964
6005
  ...cfg,
5965
6006
  pollIntervalMs: cfg.pollIntervalMs ?? 1,
6007
+ pollBackoffMinMs: cfg.pollBackoffMinMs ?? DEFAULT_POLL_BACKOFF_MIN_MS,
6008
+ pollBackoffMaxMs: cfg.pollBackoffMaxMs ?? DEFAULT_POLL_BACKOFF_MAX_MS,
5966
6009
  autoStart: cfg.autoStart ?? true,
5967
6010
  validateSchemas: cfg.validateSchemas ?? false,
5968
6011
  maxParallelJobs: cfg.maxParallelJobs ?? 10,
@@ -6194,6 +6237,7 @@ var ThreadedJobWorker = class {
6194
6237
  this._inFlightActivation = this._client.activateJobs(body);
6195
6238
  const activation = await this._inFlightActivation;
6196
6239
  this._inFlightActivation = null;
6240
+ this._consecutiveActivationErrors = 0;
6197
6241
  result = activation?.jobs || [];
6198
6242
  this._log.debug(() => ["activation.response", { jobs: result.length }]);
6199
6243
  } catch (e) {
@@ -6201,10 +6245,17 @@ var ThreadedJobWorker = class {
6201
6245
  if (this._stopped) return;
6202
6246
  if (e?.name === "CancelSdkError") {
6203
6247
  this._log.debug("activation.cancelled");
6204
- } else {
6205
- this._log.error("activation.error", e);
6248
+ this._scheduleNext(this._cfg.pollIntervalMs);
6249
+ return;
6206
6250
  }
6207
- this._scheduleNext(this._cfg.pollIntervalMs);
6251
+ this._consecutiveActivationErrors += 1;
6252
+ const delayMs = nextActivationRetryDelayMs(this._consecutiveActivationErrors, this._cfg);
6253
+ this._log.error("activation.error", e);
6254
+ this._log.debug(() => [
6255
+ "activation.retry",
6256
+ { attempt: this._consecutiveActivationErrors, retryInMs: delayMs }
6257
+ ]);
6258
+ this._scheduleNext(delayMs);
6208
6259
  return;
6209
6260
  }
6210
6261
  if (!result || result.length === 0) {
@@ -19692,4 +19743,4 @@ export {
19692
19743
  withTimeoutTE,
19693
19744
  eventuallyTE
19694
19745
  };
19695
- //# sourceMappingURL=chunk-GUNQU6UN.js.map
19746
+ //# sourceMappingURL=chunk-5T5DTO7V.js.map