@rivetkit/workflow-engine 0.0.0-sqlite-sync-3-0-0-release.14341d0 → 0.0.0-sqlite-sync-3-0-1-release.95f6e2d
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/tsup/{chunk-XRITRTKT.cjs → chunk-AO3IZAQ4.cjs} +56 -11
- package/dist/tsup/chunk-AO3IZAQ4.cjs.map +1 -0
- package/dist/tsup/{chunk-AAAPEYGX.js → chunk-OQDLVTH2.js} +56 -11
- package/dist/tsup/chunk-OQDLVTH2.js.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +14 -0
- package/dist/tsup/index.d.ts +14 -0
- package/dist/tsup/index.js +1 -1
- package/dist/tsup/testing.cjs +25 -25
- package/dist/tsup/testing.js +1 -1
- package/package.json +1 -1
- package/src/context.ts +77 -13
- package/dist/tsup/chunk-AAAPEYGX.js.map +0 -1
- package/dist/tsup/chunk-XRITRTKT.cjs.map +0 -1
package/dist/tsup/index.cjs
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkAO3IZAQ4cjs = require('./chunk-AO3IZAQ4.cjs');
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
@@ -89,5 +89,5 @@ var _chunkXRITRTKTcjs = require('./chunk-XRITRTKT.cjs');
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
exports.CancelledError =
|
|
92
|
+
exports.CancelledError = _chunkAO3IZAQ4cjs.CancelledError; exports.CriticalError = _chunkAO3IZAQ4cjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkAO3IZAQ4cjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkAO3IZAQ4cjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkAO3IZAQ4cjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkAO3IZAQ4cjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkAO3IZAQ4cjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkAO3IZAQ4cjs.EntryInProgressError; exports.EvictedError = _chunkAO3IZAQ4cjs.EvictedError; exports.HistoryDivergedError = _chunkAO3IZAQ4cjs.HistoryDivergedError; exports.JoinError = _chunkAO3IZAQ4cjs.JoinError; exports.Loop = _chunkAO3IZAQ4cjs.Loop; exports.MessageWaitError = _chunkAO3IZAQ4cjs.MessageWaitError; exports.RaceError = _chunkAO3IZAQ4cjs.RaceError; exports.RollbackCheckpointError = _chunkAO3IZAQ4cjs.RollbackCheckpointError; exports.RollbackError = _chunkAO3IZAQ4cjs.RollbackError; exports.SleepError = _chunkAO3IZAQ4cjs.SleepError; exports.StepExhaustedError = _chunkAO3IZAQ4cjs.StepExhaustedError; exports.StepFailedError = _chunkAO3IZAQ4cjs.StepFailedError; exports.WorkflowContextImpl = _chunkAO3IZAQ4cjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkAO3IZAQ4cjs.appendLoopIteration; exports.appendName = _chunkAO3IZAQ4cjs.appendName; exports.createEntry = _chunkAO3IZAQ4cjs.createEntry; exports.createHistorySnapshot = _chunkAO3IZAQ4cjs.createHistorySnapshot; exports.createStorage = _chunkAO3IZAQ4cjs.createStorage; exports.deleteEntriesWithPrefix = _chunkAO3IZAQ4cjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkAO3IZAQ4cjs.emptyLocation; exports.extractErrorInfo = _chunkAO3IZAQ4cjs.extractErrorInfo; exports.flush = _chunkAO3IZAQ4cjs.flush; exports.generateId = _chunkAO3IZAQ4cjs.generateId; exports.getEntry = _chunkAO3IZAQ4cjs.getEntry; exports.getOrCreateMetadata = _chunkAO3IZAQ4cjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkAO3IZAQ4cjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkAO3IZAQ4cjs.isLoopIterationMarker; exports.loadMetadata = _chunkAO3IZAQ4cjs.loadMetadata; exports.loadStorage = _chunkAO3IZAQ4cjs.loadStorage; exports.locationToKey = _chunkAO3IZAQ4cjs.locationToKey; exports.locationsEqual = _chunkAO3IZAQ4cjs.locationsEqual; exports.parentLocation = _chunkAO3IZAQ4cjs.parentLocation; exports.registerName = _chunkAO3IZAQ4cjs.registerName; exports.replayWorkflowFromStep = _chunkAO3IZAQ4cjs.replayWorkflowFromStep; exports.resolveName = _chunkAO3IZAQ4cjs.resolveName; exports.runWorkflow = _chunkAO3IZAQ4cjs.runWorkflow; exports.setEntry = _chunkAO3IZAQ4cjs.setEntry;
|
|
93
93
|
//# sourceMappingURL=index.cjs.map
|
package/dist/tsup/index.d.cts
CHANGED
|
@@ -729,6 +729,20 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
729
729
|
* Mark a key as visited.
|
|
730
730
|
*/
|
|
731
731
|
private markVisited;
|
|
732
|
+
/**
|
|
733
|
+
* Mark all retained history under `location` as visited.
|
|
734
|
+
*
|
|
735
|
+
* Replay does not re-enter a settled scope, but its entries stay in history.
|
|
736
|
+
* Without this, an enclosing validateComplete or getVersion treats them as
|
|
737
|
+
* leftovers from changed workflow code.
|
|
738
|
+
*/
|
|
739
|
+
private markSettledHistoryVisited;
|
|
740
|
+
/**
|
|
741
|
+
* Mark the retained history of a resumed loop's finished iterations as
|
|
742
|
+
* visited, because the loop continues from `resumeIteration` without
|
|
743
|
+
* replaying them.
|
|
744
|
+
*/
|
|
745
|
+
private markFinishedIterationsVisited;
|
|
732
746
|
/**
|
|
733
747
|
* Check if a name has already been used at the current location in this execution.
|
|
734
748
|
* Throws HistoryDivergedError if duplicate detected.
|
package/dist/tsup/index.d.ts
CHANGED
|
@@ -729,6 +729,20 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
729
729
|
* Mark a key as visited.
|
|
730
730
|
*/
|
|
731
731
|
private markVisited;
|
|
732
|
+
/**
|
|
733
|
+
* Mark all retained history under `location` as visited.
|
|
734
|
+
*
|
|
735
|
+
* Replay does not re-enter a settled scope, but its entries stay in history.
|
|
736
|
+
* Without this, an enclosing validateComplete or getVersion treats them as
|
|
737
|
+
* leftovers from changed workflow code.
|
|
738
|
+
*/
|
|
739
|
+
private markSettledHistoryVisited;
|
|
740
|
+
/**
|
|
741
|
+
* Mark the retained history of a resumed loop's finished iterations as
|
|
742
|
+
* visited, because the loop continues from `resumeIteration` without
|
|
743
|
+
* replaying them.
|
|
744
|
+
*/
|
|
745
|
+
private markFinishedIterationsVisited;
|
|
732
746
|
/**
|
|
733
747
|
* Check if a name has already been used at the current location in this execution.
|
|
734
748
|
* Throws HistoryDivergedError if duplicate detected.
|
package/dist/tsup/index.js
CHANGED
package/dist/tsup/testing.cjs
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
var
|
|
50
|
+
var _chunkAO3IZAQ4cjs = require('./chunk-AO3IZAQ4.cjs');
|
|
51
51
|
|
|
52
52
|
// src/testing.ts
|
|
53
53
|
var InMemoryWorkflowMessageDriver = class {
|
|
@@ -97,7 +97,7 @@ var InMemoryWorkflowMessageDriver = class {
|
|
|
97
97
|
}
|
|
98
98
|
async waitForMessages(messageNames, abortSignal) {
|
|
99
99
|
if (abortSignal.aborted) {
|
|
100
|
-
throw new (0,
|
|
100
|
+
throw new (0, _chunkAO3IZAQ4cjs.EvictedError)();
|
|
101
101
|
}
|
|
102
102
|
const nameSet = messageNames.length > 0 ? new Set(messageNames) : void 0;
|
|
103
103
|
if (this.#messages.some(
|
|
@@ -118,7 +118,7 @@ var InMemoryWorkflowMessageDriver = class {
|
|
|
118
118
|
},
|
|
119
119
|
abortSignal,
|
|
120
120
|
onAbort: () => {
|
|
121
|
-
waiter.reject(new (0,
|
|
121
|
+
waiter.reject(new (0, _chunkAO3IZAQ4cjs.EvictedError)());
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
abortSignal.addEventListener("abort", waiter.onAbort, {
|
|
@@ -158,62 +158,62 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
158
158
|
__init4() {this.workerPollInterval = 100}
|
|
159
159
|
__init5() {this.messageDriver = this.#inMemoryMessageDriver}
|
|
160
160
|
async get(key) {
|
|
161
|
-
await
|
|
162
|
-
const entry = this.kv.get(
|
|
161
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
162
|
+
const entry = this.kv.get(_chunkAO3IZAQ4cjs.keyToHex.call(void 0, key));
|
|
163
163
|
return _nullishCoalesce((entry == null ? void 0 : entry.value), () => ( null));
|
|
164
164
|
}
|
|
165
165
|
async set(key, value) {
|
|
166
|
-
await
|
|
167
|
-
this.kv.set(
|
|
166
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
167
|
+
this.kv.set(_chunkAO3IZAQ4cjs.keyToHex.call(void 0, key), { key, value });
|
|
168
168
|
}
|
|
169
169
|
async delete(key) {
|
|
170
|
-
await
|
|
171
|
-
this.kv.delete(
|
|
170
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
171
|
+
this.kv.delete(_chunkAO3IZAQ4cjs.keyToHex.call(void 0, key));
|
|
172
172
|
}
|
|
173
173
|
async batchDelete(keys) {
|
|
174
|
-
await
|
|
174
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
175
175
|
for (const key of keys) {
|
|
176
|
-
this.kv.delete(
|
|
176
|
+
this.kv.delete(_chunkAO3IZAQ4cjs.keyToHex.call(void 0, key));
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
async deletePrefix(prefix) {
|
|
180
|
-
await
|
|
180
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
181
181
|
for (const [hexKey, entry] of this.kv) {
|
|
182
|
-
if (
|
|
182
|
+
if (_chunkAO3IZAQ4cjs.keyStartsWith.call(void 0, entry.key, prefix)) {
|
|
183
183
|
this.kv.delete(hexKey);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
async deleteRange(start, end) {
|
|
188
|
-
await
|
|
188
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
189
189
|
for (const [hexKey, entry] of this.kv) {
|
|
190
|
-
if (
|
|
190
|
+
if (_chunkAO3IZAQ4cjs.compareKeys.call(void 0, entry.key, start) >= 0 && _chunkAO3IZAQ4cjs.compareKeys.call(void 0, entry.key, end) < 0) {
|
|
191
191
|
this.kv.delete(hexKey);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
async list(prefix) {
|
|
196
|
-
await
|
|
196
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
197
197
|
const results = [];
|
|
198
198
|
for (const entry of this.kv.values()) {
|
|
199
|
-
if (
|
|
199
|
+
if (_chunkAO3IZAQ4cjs.keyStartsWith.call(void 0, entry.key, prefix)) {
|
|
200
200
|
results.push({ key: entry.key, value: entry.value });
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
return results.sort((a, b) =>
|
|
203
|
+
return results.sort((a, b) => _chunkAO3IZAQ4cjs.compareKeys.call(void 0, a.key, b.key));
|
|
204
204
|
}
|
|
205
205
|
async batch(writes) {
|
|
206
|
-
await
|
|
206
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
207
207
|
for (const { key, value } of writes) {
|
|
208
|
-
this.kv.set(
|
|
208
|
+
this.kv.set(_chunkAO3IZAQ4cjs.keyToHex.call(void 0, key), { key, value });
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
async setAlarm(workflowId, wakeAt) {
|
|
212
|
-
await
|
|
212
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
213
213
|
this.alarms.set(workflowId, wakeAt);
|
|
214
214
|
}
|
|
215
215
|
async clearAlarm(workflowId) {
|
|
216
|
-
await
|
|
216
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, this.latency);
|
|
217
217
|
this.alarms.delete(workflowId);
|
|
218
218
|
}
|
|
219
219
|
async waitForMessages(messageNames, abortSignal) {
|
|
@@ -224,7 +224,7 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
224
224
|
}
|
|
225
225
|
while (true) {
|
|
226
226
|
if (abortSignal.aborted) {
|
|
227
|
-
throw new (0,
|
|
227
|
+
throw new (0, _chunkAO3IZAQ4cjs.EvictedError)();
|
|
228
228
|
}
|
|
229
229
|
const messages = await this.messageDriver.receiveMessages({
|
|
230
230
|
names: messageNames.length > 0 ? messageNames : void 0,
|
|
@@ -234,7 +234,7 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
234
234
|
if (messages.length > 0) {
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
|
-
await
|
|
237
|
+
await _chunkAO3IZAQ4cjs.sleep.call(void 0, Math.max(1, this.latency));
|
|
238
238
|
}
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
@@ -330,5 +330,5 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
330
330
|
|
|
331
331
|
|
|
332
332
|
|
|
333
|
-
exports.CancelledError =
|
|
333
|
+
exports.CancelledError = _chunkAO3IZAQ4cjs.CancelledError; exports.CriticalError = _chunkAO3IZAQ4cjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkAO3IZAQ4cjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkAO3IZAQ4cjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkAO3IZAQ4cjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkAO3IZAQ4cjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkAO3IZAQ4cjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkAO3IZAQ4cjs.EntryInProgressError; exports.EvictedError = _chunkAO3IZAQ4cjs.EvictedError; exports.HistoryDivergedError = _chunkAO3IZAQ4cjs.HistoryDivergedError; exports.InMemoryDriver = InMemoryDriver; exports.JoinError = _chunkAO3IZAQ4cjs.JoinError; exports.Loop = _chunkAO3IZAQ4cjs.Loop; exports.MessageWaitError = _chunkAO3IZAQ4cjs.MessageWaitError; exports.RaceError = _chunkAO3IZAQ4cjs.RaceError; exports.RollbackCheckpointError = _chunkAO3IZAQ4cjs.RollbackCheckpointError; exports.RollbackError = _chunkAO3IZAQ4cjs.RollbackError; exports.SleepError = _chunkAO3IZAQ4cjs.SleepError; exports.StepExhaustedError = _chunkAO3IZAQ4cjs.StepExhaustedError; exports.StepFailedError = _chunkAO3IZAQ4cjs.StepFailedError; exports.WorkflowContextImpl = _chunkAO3IZAQ4cjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkAO3IZAQ4cjs.appendLoopIteration; exports.appendName = _chunkAO3IZAQ4cjs.appendName; exports.createEntry = _chunkAO3IZAQ4cjs.createEntry; exports.createHistorySnapshot = _chunkAO3IZAQ4cjs.createHistorySnapshot; exports.createStorage = _chunkAO3IZAQ4cjs.createStorage; exports.deleteEntriesWithPrefix = _chunkAO3IZAQ4cjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkAO3IZAQ4cjs.emptyLocation; exports.extractErrorInfo = _chunkAO3IZAQ4cjs.extractErrorInfo; exports.flush = _chunkAO3IZAQ4cjs.flush; exports.generateId = _chunkAO3IZAQ4cjs.generateId; exports.getEntry = _chunkAO3IZAQ4cjs.getEntry; exports.getOrCreateMetadata = _chunkAO3IZAQ4cjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkAO3IZAQ4cjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkAO3IZAQ4cjs.isLoopIterationMarker; exports.loadMetadata = _chunkAO3IZAQ4cjs.loadMetadata; exports.loadStorage = _chunkAO3IZAQ4cjs.loadStorage; exports.locationToKey = _chunkAO3IZAQ4cjs.locationToKey; exports.locationsEqual = _chunkAO3IZAQ4cjs.locationsEqual; exports.parentLocation = _chunkAO3IZAQ4cjs.parentLocation; exports.registerName = _chunkAO3IZAQ4cjs.registerName; exports.replayWorkflowFromStep = _chunkAO3IZAQ4cjs.replayWorkflowFromStep; exports.resolveName = _chunkAO3IZAQ4cjs.resolveName; exports.runWorkflow = _chunkAO3IZAQ4cjs.runWorkflow; exports.setEntry = _chunkAO3IZAQ4cjs.setEntry;
|
|
334
334
|
//# sourceMappingURL=testing.cjs.map
|
package/dist/tsup/testing.js
CHANGED
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -502,6 +502,48 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
502
502
|
this.visitedKeys.add(key);
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
+
/**
|
|
506
|
+
* Mark all retained history under `location` as visited.
|
|
507
|
+
*
|
|
508
|
+
* Replay does not re-enter a settled scope, but its entries stay in history.
|
|
509
|
+
* Without this, an enclosing validateComplete or getVersion treats them as
|
|
510
|
+
* leftovers from changed workflow code.
|
|
511
|
+
*/
|
|
512
|
+
private markSettledHistoryVisited(location: Location): void {
|
|
513
|
+
for (const [key, entry] of this.storage.history.entries) {
|
|
514
|
+
if (isLocationPrefix(location, entry.location)) {
|
|
515
|
+
this.markVisited(key);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Mark the retained history of a resumed loop's finished iterations as
|
|
522
|
+
* visited, because the loop continues from `resumeIteration` without
|
|
523
|
+
* replaying them.
|
|
524
|
+
*/
|
|
525
|
+
private markFinishedIterationsVisited(
|
|
526
|
+
loopLocation: Location,
|
|
527
|
+
resumeIteration: number,
|
|
528
|
+
): void {
|
|
529
|
+
const loopSegment = loopLocation[loopLocation.length - 1];
|
|
530
|
+
for (const [key, entry] of this.storage.history.entries) {
|
|
531
|
+
if (!isLocationPrefix(loopLocation, entry.location)) {
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const iterationSegment = entry.location[loopLocation.length];
|
|
536
|
+
if (
|
|
537
|
+
iterationSegment &&
|
|
538
|
+
typeof iterationSegment !== "number" &&
|
|
539
|
+
iterationSegment.loop === loopSegment &&
|
|
540
|
+
iterationSegment.iteration < resumeIteration
|
|
541
|
+
) {
|
|
542
|
+
this.markVisited(key);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
505
547
|
/**
|
|
506
548
|
* Check if a name has already been used at the current location in this execution.
|
|
507
549
|
* Throws HistoryDivergedError if duplicate detected.
|
|
@@ -1185,6 +1227,13 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
1185
1227
|
existing.id,
|
|
1186
1228
|
);
|
|
1187
1229
|
|
|
1230
|
+
if (
|
|
1231
|
+
metadata.status === "completed" ||
|
|
1232
|
+
loopData.output !== undefined
|
|
1233
|
+
) {
|
|
1234
|
+
this.markSettledHistoryVisited(location);
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1188
1237
|
if (rollbackMode) {
|
|
1189
1238
|
if (loopData.output !== undefined) {
|
|
1190
1239
|
return loopData.output as T;
|
|
@@ -1207,6 +1256,7 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
1207
1256
|
entry = existing;
|
|
1208
1257
|
state = loopData.state as S;
|
|
1209
1258
|
iteration = loopData.iteration;
|
|
1259
|
+
this.markFinishedIterationsVisited(location, iteration);
|
|
1210
1260
|
if (rollbackMode) {
|
|
1211
1261
|
rollbackOutput = loopData.output as T | undefined;
|
|
1212
1262
|
rollbackIterationRan = rollbackOutput !== undefined;
|
|
@@ -2097,24 +2147,27 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
2097
2147
|
);
|
|
2098
2148
|
}
|
|
2099
2149
|
|
|
2150
|
+
const branchLocation = appendName(
|
|
2151
|
+
this.storage,
|
|
2152
|
+
location,
|
|
2153
|
+
branchName,
|
|
2154
|
+
);
|
|
2155
|
+
|
|
2100
2156
|
// Already completed
|
|
2101
2157
|
if (branchStatus.status === "completed") {
|
|
2158
|
+
this.markSettledHistoryVisited(branchLocation);
|
|
2102
2159
|
results[branchName] = branchStatus.output;
|
|
2103
2160
|
return;
|
|
2104
2161
|
}
|
|
2105
2162
|
|
|
2106
2163
|
// Already failed
|
|
2107
2164
|
if (branchStatus.status === "failed") {
|
|
2165
|
+
this.markSettledHistoryVisited(branchLocation);
|
|
2108
2166
|
errors[branchName] = new Error(branchStatus.error);
|
|
2109
2167
|
return;
|
|
2110
2168
|
}
|
|
2111
2169
|
|
|
2112
2170
|
// Execute branch
|
|
2113
|
-
const branchLocation = appendName(
|
|
2114
|
-
this.storage,
|
|
2115
|
-
location,
|
|
2116
|
-
branchName,
|
|
2117
|
-
);
|
|
2118
2171
|
const branchCtx = this.createBranch(branchLocation);
|
|
2119
2172
|
|
|
2120
2173
|
branchStatus.status = "running";
|
|
@@ -2257,6 +2310,7 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
2257
2310
|
// Check if we already have a winner
|
|
2258
2311
|
const raceKind = existing.kind;
|
|
2259
2312
|
if (raceKind.data.winner !== null) {
|
|
2313
|
+
this.markSettledHistoryVisited(location);
|
|
2260
2314
|
const winnerStatus =
|
|
2261
2315
|
raceKind.data.branches[raceKind.data.winner];
|
|
2262
2316
|
return {
|
|
@@ -2333,6 +2387,7 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
2333
2387
|
|
|
2334
2388
|
// If we found a replay winner, return immediately
|
|
2335
2389
|
if (hasWinner && winnerName !== null) {
|
|
2390
|
+
this.markSettledHistoryVisited(location);
|
|
2336
2391
|
return { winner: winnerName, value: winnerValue as T };
|
|
2337
2392
|
}
|
|
2338
2393
|
|
|
@@ -2345,19 +2400,21 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
2345
2400
|
);
|
|
2346
2401
|
}
|
|
2347
2402
|
|
|
2403
|
+
const branchLocation = appendName(
|
|
2404
|
+
this.storage,
|
|
2405
|
+
location,
|
|
2406
|
+
branch.name,
|
|
2407
|
+
);
|
|
2408
|
+
|
|
2348
2409
|
// Skip already completed/cancelled
|
|
2349
2410
|
if (
|
|
2350
2411
|
branchStatus.status !== "pending" &&
|
|
2351
2412
|
branchStatus.status !== "running"
|
|
2352
2413
|
) {
|
|
2414
|
+
this.markSettledHistoryVisited(branchLocation);
|
|
2353
2415
|
continue;
|
|
2354
2416
|
}
|
|
2355
2417
|
|
|
2356
|
-
const branchLocation = appendName(
|
|
2357
|
-
this.storage,
|
|
2358
|
-
location,
|
|
2359
|
-
branch.name,
|
|
2360
|
-
);
|
|
2361
2418
|
const branchCtx = this.createBranch(
|
|
2362
2419
|
branchLocation,
|
|
2363
2420
|
raceAbortController,
|
|
@@ -2367,7 +2424,15 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
2367
2424
|
branchStatus.error = undefined;
|
|
2368
2425
|
entry.dirty = true;
|
|
2369
2426
|
|
|
2370
|
-
|
|
2427
|
+
// Validate inside the run promise so a divergence reaches the
|
|
2428
|
+
// rejection handler below instead of being dropped by allSettled.
|
|
2429
|
+
const runBranch = async () => {
|
|
2430
|
+
const output = await branch.run(branchCtx);
|
|
2431
|
+
branchCtx.validateComplete();
|
|
2432
|
+
return output;
|
|
2433
|
+
};
|
|
2434
|
+
|
|
2435
|
+
const branchPromise = runBranch().then(
|
|
2371
2436
|
async (output) => {
|
|
2372
2437
|
if (hasWinner) {
|
|
2373
2438
|
// This branch completed after a winner was determined
|
|
@@ -2391,8 +2456,6 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
2391
2456
|
winnerName = branch.name;
|
|
2392
2457
|
winnerValue = output;
|
|
2393
2458
|
|
|
2394
|
-
branchCtx.validateComplete();
|
|
2395
|
-
|
|
2396
2459
|
branchStatus.status = "completed";
|
|
2397
2460
|
branchStatus.output = output;
|
|
2398
2461
|
branchStatus.error = undefined;
|
|
@@ -2583,6 +2646,7 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
2583
2646
|
}
|
|
2584
2647
|
|
|
2585
2648
|
// If it's not already marked as removed, we just skip it
|
|
2649
|
+
this.markSettledHistoryVisited(location);
|
|
2586
2650
|
return;
|
|
2587
2651
|
}
|
|
2588
2652
|
|