@workglow/task-graph 0.2.18 → 0.2.20

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/browser.js CHANGED
@@ -1435,6 +1435,7 @@ class TaskRunner {
1435
1435
  timeoutTimer;
1436
1436
  pendingTimeoutError;
1437
1437
  shouldAccumulate = true;
1438
+ runWithPreviews = false;
1438
1439
  telemetrySpan;
1439
1440
  constructor(task) {
1440
1441
  this.task = task;
@@ -1717,6 +1718,7 @@ class TaskRunner {
1717
1718
  this.outputCache = cache;
1718
1719
  }
1719
1720
  this.shouldAccumulate = config.shouldAccumulate !== false;
1721
+ this.runWithPreviews = config.runWithPreviews === true;
1720
1722
  if (config.updateProgress) {
1721
1723
  this.updateProgress = config.updateProgress;
1722
1724
  }
@@ -2888,6 +2890,7 @@ class TaskGraphRunner {
2888
2890
  graph;
2889
2891
  outputCache;
2890
2892
  accumulateLeafOutputs = true;
2893
+ runWithPreviews = false;
2891
2894
  registry = globalServiceRegistry3;
2892
2895
  resourceScope;
2893
2896
  abortController;
@@ -3131,12 +3134,13 @@ class TaskGraphRunner {
3131
3134
  consumerCounts.set(port, (consumerCounts.get(port) ?? 0) + 1);
3132
3135
  }
3133
3136
  for (const [port, count] of consumerCounts) {
3134
- if (count <= 1)
3137
+ const extra = this.runWithPreviews ? count : count - 1;
3138
+ if (extra <= 0)
3135
3139
  continue;
3136
3140
  const value = results[port];
3137
3141
  const ref = asRefcountable(value);
3138
3142
  if (ref)
3139
- ref.retain(count - 1);
3143
+ ref.retain(extra);
3140
3144
  }
3141
3145
  }
3142
3146
  for (const dataflow of dataflows) {
@@ -3308,7 +3312,8 @@ class TaskGraphRunner {
3308
3312
  outputCache: this.outputCache ?? false,
3309
3313
  updateProgress: async (task2, progress, message, ...args) => await this.handleProgress(task2, progress, message, ...args),
3310
3314
  registry: this.registry,
3311
- resourceScope: this.resourceScope
3315
+ resourceScope: this.resourceScope,
3316
+ runWithPreviews: this.runWithPreviews
3312
3317
  });
3313
3318
  await this.pushOutputFromNodeToEdges(task, results);
3314
3319
  return {
@@ -3358,7 +3363,8 @@ class TaskGraphRunner {
3358
3363
  shouldAccumulate,
3359
3364
  updateProgress: async (task2, progress, message, ...args) => await this.handleProgress(task2, progress, message, ...args),
3360
3365
  registry: this.registry,
3361
- resourceScope: this.resourceScope
3366
+ resourceScope: this.resourceScope,
3367
+ runWithPreviews: this.runWithPreviews
3362
3368
  });
3363
3369
  await this.pushOutputFromNodeToEdges(task, results);
3364
3370
  return {
@@ -3433,6 +3439,17 @@ class TaskGraphRunner {
3433
3439
  }
3434
3440
  }
3435
3441
  resetTask(graph, task, runId) {
3442
+ const previous = task.runOutputData;
3443
+ if (previous) {
3444
+ for (const port of Object.keys(previous)) {
3445
+ const ref = asRefcountable(previous[port]);
3446
+ if (!ref)
3447
+ continue;
3448
+ try {
3449
+ ref.release();
3450
+ } catch {}
3451
+ }
3452
+ }
3436
3453
  task.status = TaskStatus.PENDING;
3437
3454
  task.resetInputData();
3438
3455
  task.runOutputData = {};
@@ -3466,6 +3483,7 @@ class TaskGraphRunner {
3466
3483
  this.resourceScope = config.resourceScope;
3467
3484
  }
3468
3485
  this.accumulateLeafOutputs = config?.accumulateLeafOutputs !== false;
3486
+ this.runWithPreviews = config?.runWithPreviews === true;
3469
3487
  if (config?.outputCache !== undefined) {
3470
3488
  if (typeof config.outputCache === "boolean") {
3471
3489
  if (config.outputCache === true) {
@@ -3565,6 +3583,7 @@ class TaskGraphRunner {
3565
3583
  throw new TaskConfigurationError(`Graph has ${taskCount} tasks, exceeding the limit of ${config.maxTasks}`);
3566
3584
  }
3567
3585
  }
3586
+ this.runWithPreviews = false;
3568
3587
  this.previewScheduler.reset();
3569
3588
  this.previewRunning = true;
3570
3589
  }
@@ -3664,7 +3683,8 @@ class GraphAsTaskRunner extends TaskRunner {
3664
3683
  parentSignal: this.abortController?.signal,
3665
3684
  outputCache: this.outputCache,
3666
3685
  registry: this.registry,
3667
- resourceScope: this.resourceScope
3686
+ resourceScope: this.resourceScope,
3687
+ runWithPreviews: this.runWithPreviews
3668
3688
  });
3669
3689
  unsubscribe();
3670
3690
  return results;
@@ -4127,7 +4147,8 @@ class TaskGraph {
4127
4147
  registry: config?.registry,
4128
4148
  timeout: config?.timeout,
4129
4149
  maxTasks: config?.maxTasks,
4130
- resourceScope: config?.resourceScope
4150
+ resourceScope: config?.resourceScope,
4151
+ runWithPreviews: config?.runWithPreviews
4131
4152
  });
4132
4153
  }
4133
4154
  runPreview(input = {}, config = {}) {
@@ -4980,7 +5001,8 @@ class Workflow {
4980
5001
  parentSignal: this._abortController.signal,
4981
5002
  outputCache: this._outputCache,
4982
5003
  registry: config?.registry ?? this._registry,
4983
- resourceScope: config?.resourceScope
5004
+ resourceScope: config?.resourceScope,
5005
+ runWithPreviews: config?.runWithPreviews
4984
5006
  });
4985
5007
  const results = this.graph.mergeExecuteOutputsToRunOutput(output, PROPERTY_ARRAY);
4986
5008
  this.events.emit("complete");
@@ -9044,4 +9066,4 @@ export {
9044
9066
  BROWSER_GRANTS
9045
9067
  };
9046
9068
 
9047
- //# debugId=09531002308E754B64756E2164756E21
9069
+ //# debugId=DACDDF54D5A4197B64756E2164756E21