@rivetkit/workflow-engine 0.0.0-skip-ready-wait-flatten-client-options.1cae221 → 0.0.0-sqlite-uds.4e59a38
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/schemas/v1.ts +25 -0
- package/dist/tsup/{chunk-SFJQFMCW.cjs → chunk-OCUQRGRS.cjs} +184 -77
- package/dist/tsup/chunk-OCUQRGRS.cjs.map +1 -0
- package/dist/tsup/{chunk-CIDHCIH7.js → chunk-Z3WC5MXC.js} +184 -77
- package/dist/tsup/chunk-Z3WC5MXC.js.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +40 -13
- package/dist/tsup/index.d.ts +40 -13
- package/dist/tsup/index.js +1 -1
- package/dist/tsup/testing.cjs +23 -23
- package/dist/tsup/testing.js +1 -1
- package/package.json +1 -1
- package/schemas/serde.ts +17 -3
- package/schemas/v1.bare +10 -1
- package/schemas/versioned.ts +1 -0
- package/src/context.ts +140 -49
- package/src/index.ts +41 -21
- package/src/location.ts +1 -1
- package/src/types.ts +20 -3
- package/dist/tsup/chunk-CIDHCIH7.js.map +0 -1
- package/dist/tsup/chunk-SFJQFMCW.cjs.map +0 -1
package/dist/schemas/v1.ts
CHANGED
|
@@ -446,6 +446,23 @@ export function writeRemovedEntry(bc: bare.ByteCursor, x: RemovedEntry): void {
|
|
|
446
446
|
write1(bc, x.originalName)
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
+
export type VersionCheckEntry = {
|
|
450
|
+
readonly resolved: u32,
|
|
451
|
+
readonly latest: u32,
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
export function readVersionCheckEntry(bc: bare.ByteCursor): VersionCheckEntry {
|
|
455
|
+
return {
|
|
456
|
+
resolved: bare.readU32(bc),
|
|
457
|
+
latest: bare.readU32(bc),
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export function writeVersionCheckEntry(bc: bare.ByteCursor, x: VersionCheckEntry): void {
|
|
462
|
+
bare.writeU32(bc, x.resolved)
|
|
463
|
+
bare.writeU32(bc, x.latest)
|
|
464
|
+
}
|
|
465
|
+
|
|
449
466
|
export type EntryKind =
|
|
450
467
|
| { readonly tag: "StepEntry", readonly val: StepEntry }
|
|
451
468
|
| { readonly tag: "LoopEntry", readonly val: LoopEntry }
|
|
@@ -455,6 +472,7 @@ export type EntryKind =
|
|
|
455
472
|
| { readonly tag: "JoinEntry", readonly val: JoinEntry }
|
|
456
473
|
| { readonly tag: "RaceEntry", readonly val: RaceEntry }
|
|
457
474
|
| { readonly tag: "RemovedEntry", readonly val: RemovedEntry }
|
|
475
|
+
| { readonly tag: "VersionCheckEntry", readonly val: VersionCheckEntry }
|
|
458
476
|
|
|
459
477
|
export function readEntryKind(bc: bare.ByteCursor): EntryKind {
|
|
460
478
|
const offset = bc.offset
|
|
@@ -476,6 +494,8 @@ export function readEntryKind(bc: bare.ByteCursor): EntryKind {
|
|
|
476
494
|
return { tag: "RaceEntry", val: readRaceEntry(bc) }
|
|
477
495
|
case 7:
|
|
478
496
|
return { tag: "RemovedEntry", val: readRemovedEntry(bc) }
|
|
497
|
+
case 8:
|
|
498
|
+
return { tag: "VersionCheckEntry", val: readVersionCheckEntry(bc) }
|
|
479
499
|
default: {
|
|
480
500
|
bc.offset = offset
|
|
481
501
|
throw new bare.BareError(offset, "invalid tag")
|
|
@@ -525,6 +545,11 @@ export function writeEntryKind(bc: bare.ByteCursor, x: EntryKind): void {
|
|
|
525
545
|
writeRemovedEntry(bc, x.val)
|
|
526
546
|
break
|
|
527
547
|
}
|
|
548
|
+
case "VersionCheckEntry": {
|
|
549
|
+
bare.writeU8(bc, 8)
|
|
550
|
+
writeVersionCheckEntry(bc, x.val)
|
|
551
|
+
break
|
|
552
|
+
}
|
|
528
553
|
}
|
|
529
554
|
}
|
|
530
555
|
|
|
@@ -670,6 +670,16 @@ function writeRemovedEntry(bc, x) {
|
|
|
670
670
|
bare.writeString(bc, x.originalType);
|
|
671
671
|
write1(bc, x.originalName);
|
|
672
672
|
}
|
|
673
|
+
function readVersionCheckEntry(bc) {
|
|
674
|
+
return {
|
|
675
|
+
resolved: bare.readU32(bc),
|
|
676
|
+
latest: bare.readU32(bc)
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
function writeVersionCheckEntry(bc, x) {
|
|
680
|
+
bare.writeU32(bc, x.resolved);
|
|
681
|
+
bare.writeU32(bc, x.latest);
|
|
682
|
+
}
|
|
673
683
|
function readEntryKind(bc) {
|
|
674
684
|
const offset = bc.offset;
|
|
675
685
|
const tag = bare.readU8(bc);
|
|
@@ -690,6 +700,8 @@ function readEntryKind(bc) {
|
|
|
690
700
|
return { tag: "RaceEntry", val: readRaceEntry(bc) };
|
|
691
701
|
case 7:
|
|
692
702
|
return { tag: "RemovedEntry", val: readRemovedEntry(bc) };
|
|
703
|
+
case 8:
|
|
704
|
+
return { tag: "VersionCheckEntry", val: readVersionCheckEntry(bc) };
|
|
693
705
|
default: {
|
|
694
706
|
bc.offset = offset;
|
|
695
707
|
throw new bare.BareError(offset, "invalid tag");
|
|
@@ -738,6 +750,11 @@ function writeEntryKind(bc, x) {
|
|
|
738
750
|
writeRemovedEntry(bc, x.val);
|
|
739
751
|
break;
|
|
740
752
|
}
|
|
753
|
+
case "VersionCheckEntry": {
|
|
754
|
+
bare.writeU8(bc, 8);
|
|
755
|
+
writeVersionCheckEntry(bc, x.val);
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
741
758
|
}
|
|
742
759
|
}
|
|
743
760
|
function readEntry(bc) {
|
|
@@ -1182,6 +1199,14 @@ function entryKindToBare(kind) {
|
|
|
1182
1199
|
originalName: _nullishCoalesce(kind.data.originalName, () => ( null))
|
|
1183
1200
|
}
|
|
1184
1201
|
};
|
|
1202
|
+
case "version_check":
|
|
1203
|
+
return {
|
|
1204
|
+
tag: "VersionCheckEntry",
|
|
1205
|
+
val: {
|
|
1206
|
+
resolved: kind.data.resolved,
|
|
1207
|
+
latest: kind.data.latest
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1185
1210
|
}
|
|
1186
1211
|
}
|
|
1187
1212
|
function entryKindFromBare(kind) {
|
|
@@ -1263,6 +1288,14 @@ function entryKindFromBare(kind) {
|
|
|
1263
1288
|
originalName: _nullishCoalesce(kind.val.originalName, () => ( void 0))
|
|
1264
1289
|
}
|
|
1265
1290
|
};
|
|
1291
|
+
case "VersionCheckEntry":
|
|
1292
|
+
return {
|
|
1293
|
+
type: "version_check",
|
|
1294
|
+
data: {
|
|
1295
|
+
resolved: kind.val.resolved,
|
|
1296
|
+
latest: kind.val.latest
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1266
1299
|
default:
|
|
1267
1300
|
throw new Error(
|
|
1268
1301
|
`Unknown entry kind: ${kind.tag}`
|
|
@@ -1664,30 +1697,6 @@ function setEntry(storage, location, entry) {
|
|
|
1664
1697
|
storage.history.entries.set(key, entry);
|
|
1665
1698
|
}
|
|
1666
1699
|
|
|
1667
|
-
// src/utils.ts
|
|
1668
|
-
function sleep(ms) {
|
|
1669
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1670
|
-
}
|
|
1671
|
-
var TIMEOUT_MAX = 2147483647;
|
|
1672
|
-
function setLongTimeout(listener, after) {
|
|
1673
|
-
let timeout;
|
|
1674
|
-
function start(remaining) {
|
|
1675
|
-
if (remaining <= TIMEOUT_MAX) {
|
|
1676
|
-
timeout = setTimeout(listener, remaining);
|
|
1677
|
-
} else {
|
|
1678
|
-
timeout = setTimeout(() => {
|
|
1679
|
-
start(remaining - TIMEOUT_MAX);
|
|
1680
|
-
}, TIMEOUT_MAX);
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
start(after);
|
|
1684
|
-
return {
|
|
1685
|
-
abort: () => {
|
|
1686
|
-
if (timeout !== void 0) clearTimeout(timeout);
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1691
1700
|
// src/context.ts
|
|
1692
1701
|
var DEFAULT_MAX_RETRIES = 3;
|
|
1693
1702
|
var DEFAULT_RETRY_BACKOFF_BASE = 100;
|
|
@@ -1963,7 +1972,7 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
1963
1972
|
* Throws HistoryDivergedError if duplicate detected.
|
|
1964
1973
|
*/
|
|
1965
1974
|
checkDuplicateName(name) {
|
|
1966
|
-
const fullKey = locationToKey(this.storage, this.currentLocation)
|
|
1975
|
+
const fullKey = `${locationToKey(this.storage, this.currentLocation)}/${name}`;
|
|
1967
1976
|
if (this.usedNamesInExecution.has(fullKey)) {
|
|
1968
1977
|
throw new HistoryDivergedError(
|
|
1969
1978
|
`Duplicate entry name "${name}" at location "${locationToKey(this.storage, this.currentLocation)}". Each step/loop/sleep/queue.next/join/race must have a unique name within its scope.`
|
|
@@ -2017,7 +2026,7 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2017
2026
|
validateComplete() {
|
|
2018
2027
|
const prefix = locationToKey(this.storage, this.currentLocation);
|
|
2019
2028
|
for (const key of this.storage.history.entries.keys()) {
|
|
2020
|
-
const isUnderPrefix = prefix === "" ? true : key.startsWith(prefix
|
|
2029
|
+
const isUnderPrefix = prefix === "" ? true : key.startsWith(`${prefix}/`) || key === prefix;
|
|
2021
2030
|
if (isUnderPrefix) {
|
|
2022
2031
|
if (!this.visitedKeys.has(key)) {
|
|
2023
2032
|
throw new HistoryDivergedError(
|
|
@@ -2034,25 +2043,33 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2034
2043
|
this.abortController.abort(new EvictedError());
|
|
2035
2044
|
}
|
|
2036
2045
|
/**
|
|
2037
|
-
* Wait for
|
|
2038
|
-
*
|
|
2039
|
-
*
|
|
2040
|
-
*
|
|
2046
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
2047
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
2048
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
2049
|
+
* long-lived run abort signal.
|
|
2041
2050
|
*/
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2051
|
+
async sleepOrEvict(ms) {
|
|
2052
|
+
if (this.abortSignal.aborted) {
|
|
2053
|
+
throw new EvictedError();
|
|
2054
|
+
}
|
|
2055
|
+
let timer;
|
|
2056
|
+
let onAbort;
|
|
2057
|
+
try {
|
|
2058
|
+
await new Promise((resolve, reject) => {
|
|
2059
|
+
timer = setTimeout(resolve, ms);
|
|
2060
|
+
onAbort = () => reject(new EvictedError());
|
|
2061
|
+
this.abortSignal.addEventListener("abort", onAbort, {
|
|
2062
|
+
once: true
|
|
2063
|
+
});
|
|
2064
|
+
});
|
|
2065
|
+
} finally {
|
|
2066
|
+
if (timer !== void 0) {
|
|
2067
|
+
clearTimeout(timer);
|
|
2047
2068
|
}
|
|
2048
|
-
|
|
2049
|
-
"abort",
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
},
|
|
2053
|
-
{ once: true }
|
|
2054
|
-
);
|
|
2055
|
-
});
|
|
2069
|
+
if (onAbort) {
|
|
2070
|
+
this.abortSignal.removeEventListener("abort", onAbort);
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2056
2073
|
}
|
|
2057
2074
|
// === Step ===
|
|
2058
2075
|
async step(nameOrConfig, run) {
|
|
@@ -2201,7 +2218,7 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2201
2218
|
}
|
|
2202
2219
|
const maxRetries2 = _nullishCoalesce(config2.maxRetries, () => ( DEFAULT_MAX_RETRIES));
|
|
2203
2220
|
if (metadata2.attempts > maxRetries2) {
|
|
2204
|
-
const lastError =
|
|
2221
|
+
const lastError = metadata2.error;
|
|
2205
2222
|
const exhaustedError = new StepExhaustedError(
|
|
2206
2223
|
config2.name,
|
|
2207
2224
|
lastError
|
|
@@ -2290,14 +2307,13 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2290
2307
|
});
|
|
2291
2308
|
return output;
|
|
2292
2309
|
} catch (error) {
|
|
2293
|
-
if (
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2310
|
+
if (entry.kind.type === "step") {
|
|
2311
|
+
entry.kind.data.error = String(error);
|
|
2312
|
+
}
|
|
2313
|
+
entry.dirty = true;
|
|
2314
|
+
if (error instanceof StepTimeoutError && !config2.retryOnTimeout) {
|
|
2298
2315
|
metadata.status = "exhausted";
|
|
2299
2316
|
metadata.error = String(error);
|
|
2300
|
-
await this.flushStorage();
|
|
2301
2317
|
await this.notifyStepError(config2, metadata.attempts, error, {
|
|
2302
2318
|
willRetry: false
|
|
2303
2319
|
});
|
|
@@ -2311,13 +2327,8 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2311
2327
|
);
|
|
2312
2328
|
}
|
|
2313
2329
|
if (error instanceof CriticalError || error instanceof RollbackError) {
|
|
2314
|
-
if (entry.kind.type === "step") {
|
|
2315
|
-
entry.kind.data.error = String(error);
|
|
2316
|
-
}
|
|
2317
|
-
entry.dirty = true;
|
|
2318
2330
|
metadata.status = "exhausted";
|
|
2319
2331
|
metadata.error = String(error);
|
|
2320
|
-
await this.flushStorage();
|
|
2321
2332
|
await this.notifyStepError(config2, metadata.attempts, error, {
|
|
2322
2333
|
willRetry: false
|
|
2323
2334
|
});
|
|
@@ -2330,14 +2341,9 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2330
2341
|
})
|
|
2331
2342
|
);
|
|
2332
2343
|
}
|
|
2333
|
-
if (entry.kind.type === "step") {
|
|
2334
|
-
entry.kind.data.error = String(error);
|
|
2335
|
-
}
|
|
2336
|
-
entry.dirty = true;
|
|
2337
2344
|
const willRetry = metadata.attempts <= maxRetries;
|
|
2338
2345
|
metadata.status = willRetry ? "failed" : "exhausted";
|
|
2339
2346
|
metadata.error = String(error);
|
|
2340
|
-
await this.flushStorage();
|
|
2341
2347
|
if (willRetry) {
|
|
2342
2348
|
const retryDelay = calculateBackoff(
|
|
2343
2349
|
metadata.attempts,
|
|
@@ -2361,7 +2367,7 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2361
2367
|
attachTryStepFailure(
|
|
2362
2368
|
new StepExhaustedError(config2.name, String(error)),
|
|
2363
2369
|
{
|
|
2364
|
-
kind: "exhausted",
|
|
2370
|
+
kind: error instanceof StepTimeoutError ? "timeout" : "exhausted",
|
|
2365
2371
|
stepName: config2.name,
|
|
2366
2372
|
attempts: metadata.attempts,
|
|
2367
2373
|
error: extractErrorInfo(error)
|
|
@@ -2379,7 +2385,9 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2379
2385
|
*
|
|
2380
2386
|
* Note: This does NOT cancel the underlying operation. JavaScript Promises
|
|
2381
2387
|
* cannot be cancelled once started. When a timeout occurs:
|
|
2382
|
-
* - The step is
|
|
2388
|
+
* - The step is rejected with StepTimeoutError. By default this is treated
|
|
2389
|
+
* as a critical failure with no retry. Set retryOnTimeout: true on the
|
|
2390
|
+
* step config to retry timeouts like any other error.
|
|
2383
2391
|
* - The underlying async operation continues running in the background
|
|
2384
2392
|
* - Any side effects from the operation may still occur
|
|
2385
2393
|
*
|
|
@@ -2704,7 +2712,7 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
2704
2712
|
return;
|
|
2705
2713
|
}
|
|
2706
2714
|
if (remaining < this.driver.workerPollInterval) {
|
|
2707
|
-
await
|
|
2715
|
+
await this.sleepOrEvict(remaining);
|
|
2708
2716
|
this.checkEvicted();
|
|
2709
2717
|
if (entry.kind.type === "sleep") {
|
|
2710
2718
|
entry.kind.data.state = "completed";
|
|
@@ -3513,8 +3521,91 @@ var WorkflowContextImpl = (_class = class _WorkflowContextImpl {
|
|
|
3513
3521
|
setEntry(this.storage, location, entry);
|
|
3514
3522
|
await this.flushStorage();
|
|
3515
3523
|
}
|
|
3524
|
+
// === Version ===
|
|
3525
|
+
async getVersion(name, latest) {
|
|
3526
|
+
this.assertNotInProgress();
|
|
3527
|
+
this.checkEvicted();
|
|
3528
|
+
this.entryInProgress = true;
|
|
3529
|
+
try {
|
|
3530
|
+
return await this.executeGetVersion(name, latest);
|
|
3531
|
+
} finally {
|
|
3532
|
+
this.entryInProgress = false;
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
async executeGetVersion(name, latest) {
|
|
3536
|
+
if (!Number.isInteger(latest) || latest < 1) {
|
|
3537
|
+
throw new Error(
|
|
3538
|
+
`getVersion("${name}", ${latest}): latest must be an integer >= 1`
|
|
3539
|
+
);
|
|
3540
|
+
}
|
|
3541
|
+
this.checkDuplicateName(name);
|
|
3542
|
+
const location = appendName(this.storage, this.currentLocation, name);
|
|
3543
|
+
const key = locationToKey(this.storage, location);
|
|
3544
|
+
const existing = this.storage.history.entries.get(key);
|
|
3545
|
+
this.markVisited(key);
|
|
3546
|
+
this.stopRollbackIfMissing(existing);
|
|
3547
|
+
if (existing) {
|
|
3548
|
+
if (existing.kind.type !== "version_check") {
|
|
3549
|
+
throw new HistoryDivergedError(
|
|
3550
|
+
`Expected version_check at ${key}, found ${existing.kind.type}`
|
|
3551
|
+
);
|
|
3552
|
+
}
|
|
3553
|
+
return existing.kind.data.resolved;
|
|
3554
|
+
}
|
|
3555
|
+
const resolved = this.hasUnvisitedUnderCurrentScope(key) ? 1 : latest;
|
|
3556
|
+
const entry = createEntry(location, {
|
|
3557
|
+
type: "version_check",
|
|
3558
|
+
data: { resolved, latest }
|
|
3559
|
+
});
|
|
3560
|
+
setEntry(this.storage, location, entry);
|
|
3561
|
+
await this.flushStorage();
|
|
3562
|
+
return resolved;
|
|
3563
|
+
}
|
|
3564
|
+
/**
|
|
3565
|
+
* Returns true if any history entry under the current location scope
|
|
3566
|
+
* (other than `excludeKey`) has not yet been visited this run. Used by
|
|
3567
|
+
* getVersion to detect an old in-flight instance whose scope was already
|
|
3568
|
+
* executed by code that predates a version gate.
|
|
3569
|
+
*/
|
|
3570
|
+
hasUnvisitedUnderCurrentScope(excludeKey) {
|
|
3571
|
+
const prefix = locationToKey(this.storage, this.currentLocation);
|
|
3572
|
+
for (const key of this.storage.history.entries.keys()) {
|
|
3573
|
+
if (key === excludeKey) {
|
|
3574
|
+
continue;
|
|
3575
|
+
}
|
|
3576
|
+
const isUnderPrefix = prefix === "" ? true : key.startsWith(`${prefix}/`) || key === prefix;
|
|
3577
|
+
if (isUnderPrefix && !this.visitedKeys.has(key)) {
|
|
3578
|
+
return true;
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
return false;
|
|
3582
|
+
}
|
|
3516
3583
|
}, _class);
|
|
3517
3584
|
|
|
3585
|
+
// src/utils.ts
|
|
3586
|
+
function sleep(ms) {
|
|
3587
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3588
|
+
}
|
|
3589
|
+
var TIMEOUT_MAX = 2147483647;
|
|
3590
|
+
function setLongTimeout(listener, after) {
|
|
3591
|
+
let timeout;
|
|
3592
|
+
function start(remaining) {
|
|
3593
|
+
if (remaining <= TIMEOUT_MAX) {
|
|
3594
|
+
timeout = setTimeout(listener, remaining);
|
|
3595
|
+
} else {
|
|
3596
|
+
timeout = setTimeout(() => {
|
|
3597
|
+
start(remaining - TIMEOUT_MAX);
|
|
3598
|
+
}, TIMEOUT_MAX);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
start(after);
|
|
3602
|
+
return {
|
|
3603
|
+
abort: () => {
|
|
3604
|
+
if (timeout !== void 0) clearTimeout(timeout);
|
|
3605
|
+
}
|
|
3606
|
+
};
|
|
3607
|
+
}
|
|
3608
|
+
|
|
3518
3609
|
// src/index.ts
|
|
3519
3610
|
var Loop = {
|
|
3520
3611
|
continue: (state) => ({
|
|
@@ -3738,25 +3829,41 @@ async function executeLiveWorkflow(workflowId, workflowFn, input, driver, messag
|
|
|
3738
3829
|
const hasMessages = result.waitingForMessages !== void 0;
|
|
3739
3830
|
const hasDeadline = result.sleepUntil !== void 0;
|
|
3740
3831
|
if (hasMessages && hasDeadline) {
|
|
3832
|
+
const iterationAbort = new AbortController();
|
|
3833
|
+
const onRunAbort = () => iterationAbort.abort();
|
|
3834
|
+
if (abortController.signal.aborted) {
|
|
3835
|
+
iterationAbort.abort();
|
|
3836
|
+
} else {
|
|
3837
|
+
abortController.signal.addEventListener("abort", onRunAbort, {
|
|
3838
|
+
once: true
|
|
3839
|
+
});
|
|
3840
|
+
}
|
|
3841
|
+
const messagePromise = awaitWithEviction(
|
|
3842
|
+
driver.waitForMessages(
|
|
3843
|
+
result.waitingForMessages,
|
|
3844
|
+
iterationAbort.signal
|
|
3845
|
+
),
|
|
3846
|
+
iterationAbort.signal
|
|
3847
|
+
);
|
|
3848
|
+
const sleepPromise = waitForSleep(
|
|
3849
|
+
runtime,
|
|
3850
|
+
result.sleepUntil,
|
|
3851
|
+
iterationAbort.signal
|
|
3852
|
+
);
|
|
3853
|
+
messagePromise.catch(() => {
|
|
3854
|
+
});
|
|
3855
|
+
sleepPromise.catch(() => {
|
|
3856
|
+
});
|
|
3741
3857
|
try {
|
|
3742
|
-
const messagePromise = awaitWithEviction(
|
|
3743
|
-
driver.waitForMessages(
|
|
3744
|
-
result.waitingForMessages,
|
|
3745
|
-
abortController.signal
|
|
3746
|
-
),
|
|
3747
|
-
abortController.signal
|
|
3748
|
-
);
|
|
3749
|
-
const sleepPromise = waitForSleep(
|
|
3750
|
-
runtime,
|
|
3751
|
-
result.sleepUntil,
|
|
3752
|
-
abortController.signal
|
|
3753
|
-
);
|
|
3754
3858
|
await Promise.race([messagePromise, sleepPromise]);
|
|
3755
3859
|
} catch (error) {
|
|
3756
3860
|
if (error instanceof EvictedError) {
|
|
3757
3861
|
return lastResult;
|
|
3758
3862
|
}
|
|
3759
3863
|
throw error;
|
|
3864
|
+
} finally {
|
|
3865
|
+
iterationAbort.abort();
|
|
3866
|
+
abortController.signal.removeEventListener("abort", onRunAbort);
|
|
3760
3867
|
}
|
|
3761
3868
|
continue;
|
|
3762
3869
|
}
|
|
@@ -4209,5 +4316,5 @@ async function executeWorkflow(workflowId, workflowFn, input, driver, messageDri
|
|
|
4209
4316
|
|
|
4210
4317
|
|
|
4211
4318
|
|
|
4212
|
-
exports.extractErrorInfo = extractErrorInfo; exports.CriticalError = CriticalError; exports.RollbackError = RollbackError; exports.RollbackCheckpointError = RollbackCheckpointError; exports.SleepError = SleepError; exports.MessageWaitError = MessageWaitError; exports.EvictedError = EvictedError; exports.HistoryDivergedError = HistoryDivergedError; exports.StepExhaustedError = StepExhaustedError; exports.StepFailedError = StepFailedError; exports.JoinError = JoinError; exports.RaceError = RaceError; exports.CancelledError = CancelledError; exports.EntryInProgressError = EntryInProgressError; exports.keyStartsWith = keyStartsWith; exports.compareKeys = compareKeys; exports.keyToHex = keyToHex; exports.isLoopIterationMarker = isLoopIterationMarker; exports.registerName = registerName; exports.resolveName = resolveName; exports.locationToKey = locationToKey; exports.appendName = appendName; exports.appendLoopIteration = appendLoopIteration; exports.emptyLocation = emptyLocation; exports.parentLocation = parentLocation; exports.isLocationPrefix = isLocationPrefix; exports.locationsEqual = locationsEqual; exports.createStorage = createStorage; exports.createHistorySnapshot = createHistorySnapshot; exports.generateId = generateId; exports.createEntry = createEntry; exports.getOrCreateMetadata = getOrCreateMetadata; exports.loadStorage = loadStorage; exports.loadMetadata = loadMetadata; exports.flush = flush; exports.deleteEntriesWithPrefix = deleteEntriesWithPrefix; exports.getEntry = getEntry; exports.setEntry = setEntry; exports.
|
|
4213
|
-
//# sourceMappingURL=chunk-
|
|
4319
|
+
exports.extractErrorInfo = extractErrorInfo; exports.CriticalError = CriticalError; exports.RollbackError = RollbackError; exports.RollbackCheckpointError = RollbackCheckpointError; exports.SleepError = SleepError; exports.MessageWaitError = MessageWaitError; exports.EvictedError = EvictedError; exports.HistoryDivergedError = HistoryDivergedError; exports.StepExhaustedError = StepExhaustedError; exports.StepFailedError = StepFailedError; exports.JoinError = JoinError; exports.RaceError = RaceError; exports.CancelledError = CancelledError; exports.EntryInProgressError = EntryInProgressError; exports.keyStartsWith = keyStartsWith; exports.compareKeys = compareKeys; exports.keyToHex = keyToHex; exports.isLoopIterationMarker = isLoopIterationMarker; exports.registerName = registerName; exports.resolveName = resolveName; exports.locationToKey = locationToKey; exports.appendName = appendName; exports.appendLoopIteration = appendLoopIteration; exports.emptyLocation = emptyLocation; exports.parentLocation = parentLocation; exports.isLocationPrefix = isLocationPrefix; exports.locationsEqual = locationsEqual; exports.createStorage = createStorage; exports.createHistorySnapshot = createHistorySnapshot; exports.generateId = generateId; exports.createEntry = createEntry; exports.getOrCreateMetadata = getOrCreateMetadata; exports.loadStorage = loadStorage; exports.loadMetadata = loadMetadata; exports.flush = flush; exports.deleteEntriesWithPrefix = deleteEntriesWithPrefix; exports.getEntry = getEntry; exports.setEntry = setEntry; exports.DEFAULT_MAX_RETRIES = DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_STEP_TIMEOUT = DEFAULT_STEP_TIMEOUT; exports.WorkflowContextImpl = WorkflowContextImpl; exports.sleep = sleep; exports.Loop = Loop; exports.runWorkflow = runWorkflow; exports.replayWorkflowFromStep = replayWorkflowFromStep;
|
|
4320
|
+
//# sourceMappingURL=chunk-OCUQRGRS.cjs.map
|