@rivetkit/workflow-engine 2.3.0 → 2.3.2
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-U2W3KHJC.cjs → chunk-GQWOLYBA.cjs} +80 -56
- package/dist/tsup/chunk-GQWOLYBA.cjs.map +1 -0
- package/dist/tsup/{chunk-DFNXCZ47.js → chunk-KA2T56AJ.js} +80 -56
- package/dist/tsup/chunk-KA2T56AJ.js.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- package/dist/tsup/index.d.cts +5 -5
- package/dist/tsup/index.d.ts +5 -5
- 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/src/context.ts +26 -19
- package/src/index.ts +33 -13
- package/dist/tsup/chunk-DFNXCZ47.js.map +0 -1
- package/dist/tsup/chunk-U2W3KHJC.cjs.map +0 -1
package/dist/tsup/index.cjs
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkGQWOLYBAcjs = require('./chunk-GQWOLYBA.cjs');
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
@@ -89,5 +89,5 @@ var _chunkU2W3KHJCcjs = require('./chunk-U2W3KHJC.cjs');
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
exports.CancelledError =
|
|
92
|
+
exports.CancelledError = _chunkGQWOLYBAcjs.CancelledError; exports.CriticalError = _chunkGQWOLYBAcjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkGQWOLYBAcjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkGQWOLYBAcjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkGQWOLYBAcjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkGQWOLYBAcjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkGQWOLYBAcjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkGQWOLYBAcjs.EntryInProgressError; exports.EvictedError = _chunkGQWOLYBAcjs.EvictedError; exports.HistoryDivergedError = _chunkGQWOLYBAcjs.HistoryDivergedError; exports.JoinError = _chunkGQWOLYBAcjs.JoinError; exports.Loop = _chunkGQWOLYBAcjs.Loop; exports.MessageWaitError = _chunkGQWOLYBAcjs.MessageWaitError; exports.RaceError = _chunkGQWOLYBAcjs.RaceError; exports.RollbackCheckpointError = _chunkGQWOLYBAcjs.RollbackCheckpointError; exports.RollbackError = _chunkGQWOLYBAcjs.RollbackError; exports.SleepError = _chunkGQWOLYBAcjs.SleepError; exports.StepExhaustedError = _chunkGQWOLYBAcjs.StepExhaustedError; exports.StepFailedError = _chunkGQWOLYBAcjs.StepFailedError; exports.WorkflowContextImpl = _chunkGQWOLYBAcjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkGQWOLYBAcjs.appendLoopIteration; exports.appendName = _chunkGQWOLYBAcjs.appendName; exports.createEntry = _chunkGQWOLYBAcjs.createEntry; exports.createHistorySnapshot = _chunkGQWOLYBAcjs.createHistorySnapshot; exports.createStorage = _chunkGQWOLYBAcjs.createStorage; exports.deleteEntriesWithPrefix = _chunkGQWOLYBAcjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkGQWOLYBAcjs.emptyLocation; exports.extractErrorInfo = _chunkGQWOLYBAcjs.extractErrorInfo; exports.flush = _chunkGQWOLYBAcjs.flush; exports.generateId = _chunkGQWOLYBAcjs.generateId; exports.getEntry = _chunkGQWOLYBAcjs.getEntry; exports.getOrCreateMetadata = _chunkGQWOLYBAcjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkGQWOLYBAcjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkGQWOLYBAcjs.isLoopIterationMarker; exports.loadMetadata = _chunkGQWOLYBAcjs.loadMetadata; exports.loadStorage = _chunkGQWOLYBAcjs.loadStorage; exports.locationToKey = _chunkGQWOLYBAcjs.locationToKey; exports.locationsEqual = _chunkGQWOLYBAcjs.locationsEqual; exports.parentLocation = _chunkGQWOLYBAcjs.parentLocation; exports.registerName = _chunkGQWOLYBAcjs.registerName; exports.replayWorkflowFromStep = _chunkGQWOLYBAcjs.replayWorkflowFromStep; exports.resolveName = _chunkGQWOLYBAcjs.resolveName; exports.runWorkflow = _chunkGQWOLYBAcjs.runWorkflow; exports.setEntry = _chunkGQWOLYBAcjs.setEntry;
|
|
93
93
|
//# sourceMappingURL=index.cjs.map
|
package/dist/tsup/index.d.cts
CHANGED
|
@@ -699,12 +699,12 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
699
699
|
*/
|
|
700
700
|
evict(): void;
|
|
701
701
|
/**
|
|
702
|
-
* Wait for
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
702
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
703
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
704
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
705
|
+
* long-lived run abort signal.
|
|
706
706
|
*/
|
|
707
|
-
|
|
707
|
+
private sleepOrEvict;
|
|
708
708
|
step<T>(nameOrConfig: string | StepConfig<T>, run?: () => Promise<T>): Promise<T>;
|
|
709
709
|
tryStep<T>(nameOrConfig: string | TryStepConfig<T>, run?: () => Promise<T>): Promise<TryStepResult<T>>;
|
|
710
710
|
try<T>(nameOrConfig: string | TryBlockConfig<T>, run?: (ctx: WorkflowContextInterface) => Promise<T>): Promise<TryBlockResult<T>>;
|
package/dist/tsup/index.d.ts
CHANGED
|
@@ -699,12 +699,12 @@ declare class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
699
699
|
*/
|
|
700
700
|
evict(): void;
|
|
701
701
|
/**
|
|
702
|
-
* Wait for
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
702
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
703
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
704
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
705
|
+
* long-lived run abort signal.
|
|
706
706
|
*/
|
|
707
|
-
|
|
707
|
+
private sleepOrEvict;
|
|
708
708
|
step<T>(nameOrConfig: string | StepConfig<T>, run?: () => Promise<T>): Promise<T>;
|
|
709
709
|
tryStep<T>(nameOrConfig: string | TryStepConfig<T>, run?: () => Promise<T>): Promise<TryStepResult<T>>;
|
|
710
710
|
try<T>(nameOrConfig: string | TryBlockConfig<T>, run?: (ctx: WorkflowContextInterface) => Promise<T>): Promise<TryBlockResult<T>>;
|
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 _chunkGQWOLYBAcjs = require('./chunk-GQWOLYBA.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, _chunkGQWOLYBAcjs.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, _chunkGQWOLYBAcjs.EvictedError)());
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
abortSignal.addEventListener("abort", waiter.onAbort, {
|
|
@@ -158,56 +158,56 @@ 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 _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
162
|
+
const entry = this.kv.get(_chunkGQWOLYBAcjs.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 _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
167
|
+
this.kv.set(_chunkGQWOLYBAcjs.keyToHex.call(void 0, key), { key, value });
|
|
168
168
|
}
|
|
169
169
|
async delete(key) {
|
|
170
|
-
await
|
|
171
|
-
this.kv.delete(
|
|
170
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
171
|
+
this.kv.delete(_chunkGQWOLYBAcjs.keyToHex.call(void 0, key));
|
|
172
172
|
}
|
|
173
173
|
async deletePrefix(prefix) {
|
|
174
|
-
await
|
|
174
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
175
175
|
for (const [hexKey, entry] of this.kv) {
|
|
176
|
-
if (
|
|
176
|
+
if (_chunkGQWOLYBAcjs.keyStartsWith.call(void 0, entry.key, prefix)) {
|
|
177
177
|
this.kv.delete(hexKey);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
async deleteRange(start, end) {
|
|
182
|
-
await
|
|
182
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
183
183
|
for (const [hexKey, entry] of this.kv) {
|
|
184
|
-
if (
|
|
184
|
+
if (_chunkGQWOLYBAcjs.compareKeys.call(void 0, entry.key, start) >= 0 && _chunkGQWOLYBAcjs.compareKeys.call(void 0, entry.key, end) < 0) {
|
|
185
185
|
this.kv.delete(hexKey);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
async list(prefix) {
|
|
190
|
-
await
|
|
190
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
191
191
|
const results = [];
|
|
192
192
|
for (const entry of this.kv.values()) {
|
|
193
|
-
if (
|
|
193
|
+
if (_chunkGQWOLYBAcjs.keyStartsWith.call(void 0, entry.key, prefix)) {
|
|
194
194
|
results.push({ key: entry.key, value: entry.value });
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
return results.sort((a, b) =>
|
|
197
|
+
return results.sort((a, b) => _chunkGQWOLYBAcjs.compareKeys.call(void 0, a.key, b.key));
|
|
198
198
|
}
|
|
199
199
|
async batch(writes) {
|
|
200
|
-
await
|
|
200
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
201
201
|
for (const { key, value } of writes) {
|
|
202
|
-
this.kv.set(
|
|
202
|
+
this.kv.set(_chunkGQWOLYBAcjs.keyToHex.call(void 0, key), { key, value });
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
async setAlarm(workflowId, wakeAt) {
|
|
206
|
-
await
|
|
206
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
207
207
|
this.alarms.set(workflowId, wakeAt);
|
|
208
208
|
}
|
|
209
209
|
async clearAlarm(workflowId) {
|
|
210
|
-
await
|
|
210
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, this.latency);
|
|
211
211
|
this.alarms.delete(workflowId);
|
|
212
212
|
}
|
|
213
213
|
async waitForMessages(messageNames, abortSignal) {
|
|
@@ -218,7 +218,7 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
218
218
|
}
|
|
219
219
|
while (true) {
|
|
220
220
|
if (abortSignal.aborted) {
|
|
221
|
-
throw new (0,
|
|
221
|
+
throw new (0, _chunkGQWOLYBAcjs.EvictedError)();
|
|
222
222
|
}
|
|
223
223
|
const messages = await this.messageDriver.receiveMessages({
|
|
224
224
|
names: messageNames.length > 0 ? messageNames : void 0,
|
|
@@ -228,7 +228,7 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
228
228
|
if (messages.length > 0) {
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
-
await
|
|
231
|
+
await _chunkGQWOLYBAcjs.sleep.call(void 0, Math.max(1, this.latency));
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
@@ -324,5 +324,5 @@ var InMemoryDriver = (_class = class {constructor() { _class.prototype.__init.ca
|
|
|
324
324
|
|
|
325
325
|
|
|
326
326
|
|
|
327
|
-
exports.CancelledError =
|
|
327
|
+
exports.CancelledError = _chunkGQWOLYBAcjs.CancelledError; exports.CriticalError = _chunkGQWOLYBAcjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkGQWOLYBAcjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkGQWOLYBAcjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkGQWOLYBAcjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkGQWOLYBAcjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkGQWOLYBAcjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkGQWOLYBAcjs.EntryInProgressError; exports.EvictedError = _chunkGQWOLYBAcjs.EvictedError; exports.HistoryDivergedError = _chunkGQWOLYBAcjs.HistoryDivergedError; exports.InMemoryDriver = InMemoryDriver; exports.JoinError = _chunkGQWOLYBAcjs.JoinError; exports.Loop = _chunkGQWOLYBAcjs.Loop; exports.MessageWaitError = _chunkGQWOLYBAcjs.MessageWaitError; exports.RaceError = _chunkGQWOLYBAcjs.RaceError; exports.RollbackCheckpointError = _chunkGQWOLYBAcjs.RollbackCheckpointError; exports.RollbackError = _chunkGQWOLYBAcjs.RollbackError; exports.SleepError = _chunkGQWOLYBAcjs.SleepError; exports.StepExhaustedError = _chunkGQWOLYBAcjs.StepExhaustedError; exports.StepFailedError = _chunkGQWOLYBAcjs.StepFailedError; exports.WorkflowContextImpl = _chunkGQWOLYBAcjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkGQWOLYBAcjs.appendLoopIteration; exports.appendName = _chunkGQWOLYBAcjs.appendName; exports.createEntry = _chunkGQWOLYBAcjs.createEntry; exports.createHistorySnapshot = _chunkGQWOLYBAcjs.createHistorySnapshot; exports.createStorage = _chunkGQWOLYBAcjs.createStorage; exports.deleteEntriesWithPrefix = _chunkGQWOLYBAcjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkGQWOLYBAcjs.emptyLocation; exports.extractErrorInfo = _chunkGQWOLYBAcjs.extractErrorInfo; exports.flush = _chunkGQWOLYBAcjs.flush; exports.generateId = _chunkGQWOLYBAcjs.generateId; exports.getEntry = _chunkGQWOLYBAcjs.getEntry; exports.getOrCreateMetadata = _chunkGQWOLYBAcjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkGQWOLYBAcjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkGQWOLYBAcjs.isLoopIterationMarker; exports.loadMetadata = _chunkGQWOLYBAcjs.loadMetadata; exports.loadStorage = _chunkGQWOLYBAcjs.loadStorage; exports.locationToKey = _chunkGQWOLYBAcjs.locationToKey; exports.locationsEqual = _chunkGQWOLYBAcjs.locationsEqual; exports.parentLocation = _chunkGQWOLYBAcjs.parentLocation; exports.registerName = _chunkGQWOLYBAcjs.registerName; exports.replayWorkflowFromStep = _chunkGQWOLYBAcjs.replayWorkflowFromStep; exports.resolveName = _chunkGQWOLYBAcjs.resolveName; exports.runWorkflow = _chunkGQWOLYBAcjs.runWorkflow; exports.setEntry = _chunkGQWOLYBAcjs.setEntry;
|
|
328
328
|
//# sourceMappingURL=testing.cjs.map
|
package/dist/tsup/testing.js
CHANGED
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -71,7 +71,6 @@ import type {
|
|
|
71
71
|
WorkflowQueueNextBatchOptions,
|
|
72
72
|
WorkflowQueueNextOptions,
|
|
73
73
|
} from "./types.js";
|
|
74
|
-
import { sleep } from "./utils.js";
|
|
75
74
|
|
|
76
75
|
/**
|
|
77
76
|
* Default values for step configuration.
|
|
@@ -601,25 +600,33 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
601
600
|
}
|
|
602
601
|
|
|
603
602
|
/**
|
|
604
|
-
* Wait for
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
603
|
+
* Wait for `ms`, rejecting early with EvictedError if the workflow is
|
|
604
|
+
* evicted. Both the timer and the abort listener are torn down on either
|
|
605
|
+
* outcome, so a completed sleep never leaves a dangling listener on the
|
|
606
|
+
* long-lived run abort signal.
|
|
608
607
|
*/
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
608
|
+
private async sleepOrEvict(ms: number): Promise<void> {
|
|
609
|
+
if (this.abortSignal.aborted) {
|
|
610
|
+
throw new EvictedError();
|
|
611
|
+
}
|
|
612
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
613
|
+
let onAbort: (() => void) | undefined;
|
|
614
|
+
try {
|
|
615
|
+
await new Promise<void>((resolve, reject) => {
|
|
616
|
+
timer = setTimeout(resolve, ms);
|
|
617
|
+
onAbort = () => reject(new EvictedError());
|
|
618
|
+
this.abortSignal.addEventListener("abort", onAbort, {
|
|
619
|
+
once: true,
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
} finally {
|
|
623
|
+
if (timer !== undefined) {
|
|
624
|
+
clearTimeout(timer);
|
|
614
625
|
}
|
|
615
|
-
|
|
616
|
-
"abort",
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
},
|
|
620
|
-
{ once: true },
|
|
621
|
-
);
|
|
622
|
-
});
|
|
626
|
+
if (onAbort) {
|
|
627
|
+
this.abortSignal.removeEventListener("abort", onAbort);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
623
630
|
}
|
|
624
631
|
|
|
625
632
|
// === Step ===
|
|
@@ -1484,7 +1491,7 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
1484
1491
|
|
|
1485
1492
|
// Short sleep: wait in memory
|
|
1486
1493
|
if (remaining < this.driver.workerPollInterval) {
|
|
1487
|
-
await
|
|
1494
|
+
await this.sleepOrEvict(remaining);
|
|
1488
1495
|
|
|
1489
1496
|
this.checkEvicted();
|
|
1490
1497
|
|
package/src/index.ts
CHANGED
|
@@ -532,26 +532,46 @@ async function executeLiveWorkflow<TInput, TOutput>(
|
|
|
532
532
|
const hasDeadline = result.sleepUntil !== undefined;
|
|
533
533
|
|
|
534
534
|
if (hasMessages && hasDeadline) {
|
|
535
|
-
// Wait for EITHER a message OR the deadline (for queue.next timeout)
|
|
535
|
+
// Wait for EITHER a message OR the deadline (for queue.next timeout).
|
|
536
|
+
// Scope both waiters to a per-iteration controller chained to the run
|
|
537
|
+
// signal so that whichever loses the race is cancelled immediately.
|
|
538
|
+
// Otherwise the loser (a message waiter or an armed sleep timer) stays
|
|
539
|
+
// registered on the long-lived run signal and leaks once per cycle.
|
|
540
|
+
const iterationAbort = new AbortController();
|
|
541
|
+
const onRunAbort = () => iterationAbort.abort();
|
|
542
|
+
if (abortController.signal.aborted) {
|
|
543
|
+
iterationAbort.abort();
|
|
544
|
+
} else {
|
|
545
|
+
abortController.signal.addEventListener("abort", onRunAbort, {
|
|
546
|
+
once: true,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
const messagePromise = awaitWithEviction(
|
|
550
|
+
driver.waitForMessages(
|
|
551
|
+
result.waitingForMessages!,
|
|
552
|
+
iterationAbort.signal,
|
|
553
|
+
),
|
|
554
|
+
iterationAbort.signal,
|
|
555
|
+
);
|
|
556
|
+
const sleepPromise = waitForSleep(
|
|
557
|
+
runtime,
|
|
558
|
+
result.sleepUntil!,
|
|
559
|
+
iterationAbort.signal,
|
|
560
|
+
);
|
|
561
|
+
// Swallow the loser's rejection once it is aborted below so it does
|
|
562
|
+
// not surface as an unhandled rejection.
|
|
563
|
+
messagePromise.catch(() => {});
|
|
564
|
+
sleepPromise.catch(() => {});
|
|
536
565
|
try {
|
|
537
|
-
const messagePromise = awaitWithEviction(
|
|
538
|
-
driver.waitForMessages(
|
|
539
|
-
result.waitingForMessages!,
|
|
540
|
-
abortController.signal,
|
|
541
|
-
),
|
|
542
|
-
abortController.signal,
|
|
543
|
-
);
|
|
544
|
-
const sleepPromise = waitForSleep(
|
|
545
|
-
runtime,
|
|
546
|
-
result.sleepUntil!,
|
|
547
|
-
abortController.signal,
|
|
548
|
-
);
|
|
549
566
|
await Promise.race([messagePromise, sleepPromise]);
|
|
550
567
|
} catch (error) {
|
|
551
568
|
if (error instanceof EvictedError) {
|
|
552
569
|
return lastResult;
|
|
553
570
|
}
|
|
554
571
|
throw error;
|
|
572
|
+
} finally {
|
|
573
|
+
iterationAbort.abort();
|
|
574
|
+
abortController.signal.removeEventListener("abort", onRunAbort);
|
|
555
575
|
}
|
|
556
576
|
continue;
|
|
557
577
|
}
|