@dudousxd/nestjs-durable-core 0.69.0 → 0.70.0

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/dist/index.cjs CHANGED
@@ -4030,6 +4030,15 @@ var WorkflowEngine = class {
4030
4030
  /**
4031
4031
  * Resume each run only if this instance can acquire its recovery lease — so when several
4032
4032
  * replicas recover or poll at once, each run is picked up by exactly one of them.
4033
+ *
4034
+ * A run this instance cannot resume is SKIPPED, not allowed to abort the batch. The canonical
4035
+ * case is skew protection: mid-rolling-deploy a pod leases a run whose workflow it does not have
4036
+ * and `resume` throws by design — but the rest of the batch is runs it can drive perfectly well,
4037
+ * and every caller here is a recovery sweep. Letting the first such run end the loop means one
4038
+ * row stops recovery for the whole deployment, and (since the callers are pollers) sends the
4039
+ * rejection into a lifecycle hook. Skipping leaves the run locked only until its lease expires,
4040
+ * for a pod that does have the workflow — which is exactly what the skew-protection error asks
4041
+ * for. Same posture as `publishEvent`'s per-subscriber isolation.
4033
4042
  */
4034
4043
  async resumeLeased(runs, nowMs = this.clock(), onLocked) {
4035
4044
  if (this.draining) return [];
@@ -4037,8 +4046,12 @@ var WorkflowEngine = class {
4037
4046
  for (const run of runs) {
4038
4047
  const acquired = await this.store.tryLockRun(run.id, this.instanceId, nowMs + this.leaseMs, nowMs);
4039
4048
  if (!acquired) continue;
4040
- const settled = onLocked ? await onLocked(run) : void 0;
4041
- results.push(settled ?? await this.resume(run.id));
4049
+ try {
4050
+ const settled = onLocked ? await onLocked(run) : void 0;
4051
+ results.push(settled ?? await this.resume(run.id));
4052
+ } catch (error2) {
4053
+ console.error(`[nestjs-durable] could not resume run ${run.id} (${run.workflow}@${run.workflowVersion}); leaving it for another instance:`, error2);
4054
+ }
4042
4055
  }
4043
4056
  return results;
4044
4057
  }
@@ -6192,12 +6205,13 @@ function mergeRunValueFacetRows(rows, opts) {
6192
6205
  const value = row.value ?? null;
6193
6206
  counts.set(value, (counts.get(value) ?? 0) + Number(row.count));
6194
6207
  }
6208
+ const needle = opts?.search?.trim().toLowerCase();
6195
6209
  const merged = [
6196
6210
  ...counts
6197
6211
  ].map(([value, count]) => ({
6198
6212
  value,
6199
6213
  count
6200
- })).filter((row) => row.count > 0).sort((a, b) => {
6214
+ })).filter((row) => row.count > 0).filter((row) => !needle || row.value?.toLowerCase().includes(needle)).sort((a, b) => {
6201
6215
  const engineA = isEngineMintedTag(a.value);
6202
6216
  const engineB = isEngineMintedTag(b.value);
6203
6217
  if (engineA !== engineB) return engineA ? 1 : -1;
@@ -6206,7 +6220,8 @@ function mergeRunValueFacetRows(rows, opts) {
6206
6220
  if (b.value === null) return -1;
6207
6221
  return a.value.localeCompare(b.value);
6208
6222
  });
6209
- return merged.slice(0, opts?.limit ?? RUN_VALUE_FACET_LIMIT);
6223
+ const offset = opts?.offset ?? 0;
6224
+ return merged.slice(offset, offset + (opts?.limit ?? RUN_VALUE_FACET_LIMIT));
6210
6225
  }
6211
6226
  __name(mergeRunValueFacetRows, "mergeRunValueFacetRows");
6212
6227
  function runValueFacetsFromRuns(runs, axis, opts) {