@rivetkit/workflow-engine 2.3.0-rc.5 → 2.3.0-rc.7
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-SFJQFMCW.cjs → chunk-A33YVYOF.cjs} +6 -17
- package/dist/tsup/chunk-A33YVYOF.cjs.map +1 -0
- package/dist/tsup/{chunk-CIDHCIH7.js → chunk-EAAPMGGE.js} +6 -17
- package/dist/tsup/chunk-EAAPMGGE.js.map +1 -0
- package/dist/tsup/index.cjs +2 -2
- 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 +6 -19
- package/dist/tsup/chunk-CIDHCIH7.js.map +0 -1
- package/dist/tsup/chunk-SFJQFMCW.cjs.map +0 -1
package/dist/tsup/index.cjs
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _chunkA33YVYOFcjs = require('./chunk-A33YVYOF.cjs');
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
@@ -89,5 +89,5 @@ var _chunkSFJQFMCWcjs = require('./chunk-SFJQFMCW.cjs');
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
exports.CancelledError =
|
|
92
|
+
exports.CancelledError = _chunkA33YVYOFcjs.CancelledError; exports.CriticalError = _chunkA33YVYOFcjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkA33YVYOFcjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkA33YVYOFcjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkA33YVYOFcjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkA33YVYOFcjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkA33YVYOFcjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkA33YVYOFcjs.EntryInProgressError; exports.EvictedError = _chunkA33YVYOFcjs.EvictedError; exports.HistoryDivergedError = _chunkA33YVYOFcjs.HistoryDivergedError; exports.JoinError = _chunkA33YVYOFcjs.JoinError; exports.Loop = _chunkA33YVYOFcjs.Loop; exports.MessageWaitError = _chunkA33YVYOFcjs.MessageWaitError; exports.RaceError = _chunkA33YVYOFcjs.RaceError; exports.RollbackCheckpointError = _chunkA33YVYOFcjs.RollbackCheckpointError; exports.RollbackError = _chunkA33YVYOFcjs.RollbackError; exports.SleepError = _chunkA33YVYOFcjs.SleepError; exports.StepExhaustedError = _chunkA33YVYOFcjs.StepExhaustedError; exports.StepFailedError = _chunkA33YVYOFcjs.StepFailedError; exports.WorkflowContextImpl = _chunkA33YVYOFcjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkA33YVYOFcjs.appendLoopIteration; exports.appendName = _chunkA33YVYOFcjs.appendName; exports.createEntry = _chunkA33YVYOFcjs.createEntry; exports.createHistorySnapshot = _chunkA33YVYOFcjs.createHistorySnapshot; exports.createStorage = _chunkA33YVYOFcjs.createStorage; exports.deleteEntriesWithPrefix = _chunkA33YVYOFcjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkA33YVYOFcjs.emptyLocation; exports.extractErrorInfo = _chunkA33YVYOFcjs.extractErrorInfo; exports.flush = _chunkA33YVYOFcjs.flush; exports.generateId = _chunkA33YVYOFcjs.generateId; exports.getEntry = _chunkA33YVYOFcjs.getEntry; exports.getOrCreateMetadata = _chunkA33YVYOFcjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkA33YVYOFcjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkA33YVYOFcjs.isLoopIterationMarker; exports.loadMetadata = _chunkA33YVYOFcjs.loadMetadata; exports.loadStorage = _chunkA33YVYOFcjs.loadStorage; exports.locationToKey = _chunkA33YVYOFcjs.locationToKey; exports.locationsEqual = _chunkA33YVYOFcjs.locationsEqual; exports.parentLocation = _chunkA33YVYOFcjs.parentLocation; exports.registerName = _chunkA33YVYOFcjs.registerName; exports.replayWorkflowFromStep = _chunkA33YVYOFcjs.replayWorkflowFromStep; exports.resolveName = _chunkA33YVYOFcjs.resolveName; exports.runWorkflow = _chunkA33YVYOFcjs.runWorkflow; exports.setEntry = _chunkA33YVYOFcjs.setEntry;
|
|
93
93
|
//# sourceMappingURL=index.cjs.map
|
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 _chunkA33YVYOFcjs = require('./chunk-A33YVYOF.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, _chunkA33YVYOFcjs.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, _chunkA33YVYOFcjs.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 _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
162
|
+
const entry = this.kv.get(_chunkA33YVYOFcjs.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 _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
167
|
+
this.kv.set(_chunkA33YVYOFcjs.keyToHex.call(void 0, key), { key, value });
|
|
168
168
|
}
|
|
169
169
|
async delete(key) {
|
|
170
|
-
await
|
|
171
|
-
this.kv.delete(
|
|
170
|
+
await _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
171
|
+
this.kv.delete(_chunkA33YVYOFcjs.keyToHex.call(void 0, key));
|
|
172
172
|
}
|
|
173
173
|
async deletePrefix(prefix) {
|
|
174
|
-
await
|
|
174
|
+
await _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
175
175
|
for (const [hexKey, entry] of this.kv) {
|
|
176
|
-
if (
|
|
176
|
+
if (_chunkA33YVYOFcjs.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 _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
183
183
|
for (const [hexKey, entry] of this.kv) {
|
|
184
|
-
if (
|
|
184
|
+
if (_chunkA33YVYOFcjs.compareKeys.call(void 0, entry.key, start) >= 0 && _chunkA33YVYOFcjs.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 _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
191
191
|
const results = [];
|
|
192
192
|
for (const entry of this.kv.values()) {
|
|
193
|
-
if (
|
|
193
|
+
if (_chunkA33YVYOFcjs.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) => _chunkA33YVYOFcjs.compareKeys.call(void 0, a.key, b.key));
|
|
198
198
|
}
|
|
199
199
|
async batch(writes) {
|
|
200
|
-
await
|
|
200
|
+
await _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
201
201
|
for (const { key, value } of writes) {
|
|
202
|
-
this.kv.set(
|
|
202
|
+
this.kv.set(_chunkA33YVYOFcjs.keyToHex.call(void 0, key), { key, value });
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
async setAlarm(workflowId, wakeAt) {
|
|
206
|
-
await
|
|
206
|
+
await _chunkA33YVYOFcjs.sleep.call(void 0, this.latency);
|
|
207
207
|
this.alarms.set(workflowId, wakeAt);
|
|
208
208
|
}
|
|
209
209
|
async clearAlarm(workflowId) {
|
|
210
|
-
await
|
|
210
|
+
await _chunkA33YVYOFcjs.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, _chunkA33YVYOFcjs.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 _chunkA33YVYOFcjs.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 = _chunkA33YVYOFcjs.CancelledError; exports.CriticalError = _chunkA33YVYOFcjs.CriticalError; exports.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL = _chunkA33YVYOFcjs.DEFAULT_LOOP_HISTORY_PRUNE_INTERVAL; exports.DEFAULT_MAX_RETRIES = _chunkA33YVYOFcjs.DEFAULT_MAX_RETRIES; exports.DEFAULT_RETRY_BACKOFF_BASE = _chunkA33YVYOFcjs.DEFAULT_RETRY_BACKOFF_BASE; exports.DEFAULT_RETRY_BACKOFF_MAX = _chunkA33YVYOFcjs.DEFAULT_RETRY_BACKOFF_MAX; exports.DEFAULT_STEP_TIMEOUT = _chunkA33YVYOFcjs.DEFAULT_STEP_TIMEOUT; exports.EntryInProgressError = _chunkA33YVYOFcjs.EntryInProgressError; exports.EvictedError = _chunkA33YVYOFcjs.EvictedError; exports.HistoryDivergedError = _chunkA33YVYOFcjs.HistoryDivergedError; exports.InMemoryDriver = InMemoryDriver; exports.JoinError = _chunkA33YVYOFcjs.JoinError; exports.Loop = _chunkA33YVYOFcjs.Loop; exports.MessageWaitError = _chunkA33YVYOFcjs.MessageWaitError; exports.RaceError = _chunkA33YVYOFcjs.RaceError; exports.RollbackCheckpointError = _chunkA33YVYOFcjs.RollbackCheckpointError; exports.RollbackError = _chunkA33YVYOFcjs.RollbackError; exports.SleepError = _chunkA33YVYOFcjs.SleepError; exports.StepExhaustedError = _chunkA33YVYOFcjs.StepExhaustedError; exports.StepFailedError = _chunkA33YVYOFcjs.StepFailedError; exports.WorkflowContextImpl = _chunkA33YVYOFcjs.WorkflowContextImpl; exports.appendLoopIteration = _chunkA33YVYOFcjs.appendLoopIteration; exports.appendName = _chunkA33YVYOFcjs.appendName; exports.createEntry = _chunkA33YVYOFcjs.createEntry; exports.createHistorySnapshot = _chunkA33YVYOFcjs.createHistorySnapshot; exports.createStorage = _chunkA33YVYOFcjs.createStorage; exports.deleteEntriesWithPrefix = _chunkA33YVYOFcjs.deleteEntriesWithPrefix; exports.emptyLocation = _chunkA33YVYOFcjs.emptyLocation; exports.extractErrorInfo = _chunkA33YVYOFcjs.extractErrorInfo; exports.flush = _chunkA33YVYOFcjs.flush; exports.generateId = _chunkA33YVYOFcjs.generateId; exports.getEntry = _chunkA33YVYOFcjs.getEntry; exports.getOrCreateMetadata = _chunkA33YVYOFcjs.getOrCreateMetadata; exports.isLocationPrefix = _chunkA33YVYOFcjs.isLocationPrefix; exports.isLoopIterationMarker = _chunkA33YVYOFcjs.isLoopIterationMarker; exports.loadMetadata = _chunkA33YVYOFcjs.loadMetadata; exports.loadStorage = _chunkA33YVYOFcjs.loadStorage; exports.locationToKey = _chunkA33YVYOFcjs.locationToKey; exports.locationsEqual = _chunkA33YVYOFcjs.locationsEqual; exports.parentLocation = _chunkA33YVYOFcjs.parentLocation; exports.registerName = _chunkA33YVYOFcjs.registerName; exports.replayWorkflowFromStep = _chunkA33YVYOFcjs.replayWorkflowFromStep; exports.resolveName = _chunkA33YVYOFcjs.resolveName; exports.runWorkflow = _chunkA33YVYOFcjs.runWorkflow; exports.setEntry = _chunkA33YVYOFcjs.setEntry;
|
|
328
328
|
//# sourceMappingURL=testing.cjs.map
|
package/dist/tsup/testing.js
CHANGED
package/package.json
CHANGED
package/src/context.ts
CHANGED
|
@@ -825,10 +825,7 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
825
825
|
const maxRetries = config.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
826
826
|
|
|
827
827
|
if (metadata.attempts > maxRetries) {
|
|
828
|
-
|
|
829
|
-
// driver implementations may persist metadata without the history
|
|
830
|
-
// entry error (e.g. partial writes/crashes between attempts).
|
|
831
|
-
const lastError = stepData.error ?? metadata.error;
|
|
828
|
+
const lastError = metadata.error;
|
|
832
829
|
const exhaustedError = new StepExhaustedError(
|
|
833
830
|
config.name,
|
|
834
831
|
lastError,
|
|
@@ -941,15 +938,15 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
941
938
|
});
|
|
942
939
|
return output;
|
|
943
940
|
} catch (error) {
|
|
941
|
+
if (entry.kind.type === "step") {
|
|
942
|
+
entry.kind.data.error = String(error);
|
|
943
|
+
}
|
|
944
|
+
entry.dirty = true;
|
|
945
|
+
|
|
944
946
|
// Timeout errors are treated as critical (no retry)
|
|
945
947
|
if (error instanceof StepTimeoutError) {
|
|
946
|
-
if (entry.kind.type === "step") {
|
|
947
|
-
entry.kind.data.error = String(error);
|
|
948
|
-
}
|
|
949
|
-
entry.dirty = true;
|
|
950
948
|
metadata.status = "exhausted";
|
|
951
949
|
metadata.error = String(error);
|
|
952
|
-
await this.flushStorage();
|
|
953
950
|
await this.notifyStepError(config, metadata.attempts, error, {
|
|
954
951
|
willRetry: false,
|
|
955
952
|
});
|
|
@@ -967,13 +964,8 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
967
964
|
error instanceof CriticalError ||
|
|
968
965
|
error instanceof RollbackError
|
|
969
966
|
) {
|
|
970
|
-
if (entry.kind.type === "step") {
|
|
971
|
-
entry.kind.data.error = String(error);
|
|
972
|
-
}
|
|
973
|
-
entry.dirty = true;
|
|
974
967
|
metadata.status = "exhausted";
|
|
975
968
|
metadata.error = String(error);
|
|
976
|
-
await this.flushStorage();
|
|
977
969
|
await this.notifyStepError(config, metadata.attempts, error, {
|
|
978
970
|
willRetry: false,
|
|
979
971
|
});
|
|
@@ -990,15 +982,10 @@ export class WorkflowContextImpl implements WorkflowContextInterface {
|
|
|
990
982
|
);
|
|
991
983
|
}
|
|
992
984
|
|
|
993
|
-
if (entry.kind.type === "step") {
|
|
994
|
-
entry.kind.data.error = String(error);
|
|
995
|
-
}
|
|
996
|
-
entry.dirty = true;
|
|
997
985
|
const willRetry = metadata.attempts <= maxRetries;
|
|
998
986
|
metadata.status = willRetry ? "failed" : "exhausted";
|
|
999
987
|
metadata.error = String(error);
|
|
1000
988
|
|
|
1001
|
-
await this.flushStorage();
|
|
1002
989
|
if (willRetry) {
|
|
1003
990
|
const retryDelay = calculateBackoff(
|
|
1004
991
|
metadata.attempts,
|