@workflow/core 4.0.1-beta.0
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/LICENSE.md +21 -0
- package/README.md +3 -0
- package/dist/builtins.d.ts +4 -0
- package/dist/builtins.d.ts.map +1 -0
- package/dist/builtins.js +13 -0
- package/dist/builtins.js.map +1 -0
- package/dist/create-hook.d.ts +123 -0
- package/dist/create-hook.d.ts.map +1 -0
- package/dist/create-hook.js +32 -0
- package/dist/create-hook.js.map +1 -0
- package/dist/define-hook.d.ts +53 -0
- package/dist/define-hook.d.ts.map +1 -0
- package/dist/define-hook.js +59 -0
- package/dist/define-hook.js.map +1 -0
- package/dist/events-consumer.d.ts +35 -0
- package/dist/events-consumer.d.ts.map +1 -0
- package/dist/events-consumer.js +72 -0
- package/dist/events-consumer.js.map +1 -0
- package/dist/global.d.ts +29 -0
- package/dist/global.d.ts.map +1 -0
- package/dist/global.js +50 -0
- package/dist/global.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +31 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +32 -0
- package/dist/logger.js.map +1 -0
- package/dist/observability.d.ts +24 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +126 -0
- package/dist/observability.js.map +1 -0
- package/dist/parse-name.d.ts +25 -0
- package/dist/parse-name.d.ts.map +1 -0
- package/dist/parse-name.js +40 -0
- package/dist/parse-name.js.map +1 -0
- package/dist/private.d.ts +26 -0
- package/dist/private.d.ts.map +1 -0
- package/dist/private.js +17 -0
- package/dist/private.js.map +1 -0
- package/dist/runtime/resume-hook.d.ts +71 -0
- package/dist/runtime/resume-hook.d.ts.map +1 -0
- package/dist/runtime/resume-hook.js +180 -0
- package/dist/runtime/resume-hook.js.map +1 -0
- package/dist/runtime/start.d.ts +28 -0
- package/dist/runtime/start.d.ts.map +1 -0
- package/dist/runtime/start.js +57 -0
- package/dist/runtime/start.js.map +1 -0
- package/dist/runtime/world.d.ts +24 -0
- package/dist/runtime/world.d.ts.map +1 -0
- package/dist/runtime/world.js +84 -0
- package/dist/runtime/world.js.map +1 -0
- package/dist/runtime.d.ts +121 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +554 -0
- package/dist/runtime.js.map +1 -0
- package/dist/schemas.d.ts +29 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +15 -0
- package/dist/schemas.js.map +1 -0
- package/dist/serialization.d.ts +188 -0
- package/dist/serialization.d.ts.map +1 -0
- package/dist/serialization.js +725 -0
- package/dist/serialization.js.map +1 -0
- package/dist/step/context-storage.d.ts +8 -0
- package/dist/step/context-storage.d.ts.map +1 -0
- package/dist/step/context-storage.js +3 -0
- package/dist/step/context-storage.js.map +1 -0
- package/dist/step/get-step-metadata.d.ts +38 -0
- package/dist/step/get-step-metadata.d.ts.map +1 -0
- package/dist/step/get-step-metadata.js +14 -0
- package/dist/step/get-step-metadata.js.map +1 -0
- package/dist/step/get-workflow-metadata.d.ts +7 -0
- package/dist/step/get-workflow-metadata.d.ts.map +1 -0
- package/dist/step/get-workflow-metadata.js +12 -0
- package/dist/step/get-workflow-metadata.js.map +1 -0
- package/dist/step.d.ts +4 -0
- package/dist/step.d.ts.map +1 -0
- package/dist/step.js +92 -0
- package/dist/step.js.map +1 -0
- package/dist/symbols.d.ts +9 -0
- package/dist/symbols.d.ts.map +1 -0
- package/dist/symbols.js +9 -0
- package/dist/symbols.js.map +1 -0
- package/dist/telemetry/semantic-conventions.d.ts +175 -0
- package/dist/telemetry/semantic-conventions.d.ts.map +1 -0
- package/dist/telemetry/semantic-conventions.js +121 -0
- package/dist/telemetry/semantic-conventions.js.map +1 -0
- package/dist/telemetry.d.ts +24 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +121 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +39 -0
- package/dist/types.js.map +1 -0
- package/dist/util.d.ts +43 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +76 -0
- package/dist/util.js.map +1 -0
- package/dist/vm/index.d.ts +17 -0
- package/dist/vm/index.d.ts.map +1 -0
- package/dist/vm/index.js +93 -0
- package/dist/vm/index.js.map +1 -0
- package/dist/vm/uuid.d.ts +10 -0
- package/dist/vm/uuid.d.ts.map +1 -0
- package/dist/vm/uuid.js +30 -0
- package/dist/vm/uuid.js.map +1 -0
- package/dist/workflow/create-hook.d.ts +7 -0
- package/dist/workflow/create-hook.d.ts.map +1 -0
- package/dist/workflow/create-hook.js +22 -0
- package/dist/workflow/create-hook.js.map +1 -0
- package/dist/workflow/define-hook.d.ts +10 -0
- package/dist/workflow/define-hook.d.ts.map +1 -0
- package/dist/workflow/define-hook.js +15 -0
- package/dist/workflow/define-hook.js.map +1 -0
- package/dist/workflow/get-workflow-metadata.d.ts +17 -0
- package/dist/workflow/get-workflow-metadata.d.ts.map +1 -0
- package/dist/workflow/get-workflow-metadata.js +11 -0
- package/dist/workflow/get-workflow-metadata.js.map +1 -0
- package/dist/workflow/hook.d.ts +4 -0
- package/dist/workflow/hook.d.ts.map +1 -0
- package/dist/workflow/hook.js +101 -0
- package/dist/workflow/hook.js.map +1 -0
- package/dist/workflow/index.d.ts +10 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +14 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/writable-stream.d.ts +3 -0
- package/dist/workflow/writable-stream.d.ts.map +1 -0
- package/dist/workflow/writable-stream.js +12 -0
- package/dist/workflow/writable-stream.js.map +1 -0
- package/dist/workflow.d.ts +3 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +454 -0
- package/dist/workflow.js.map +1 -0
- package/dist/writable-stream.d.ts +22 -0
- package/dist/writable-stream.d.ts.map +1 -0
- package/dist/writable-stream.js +16 -0
- package/dist/writable-stream.js.map +1 -0
- package/package.json +73 -0
package/dist/runtime.js
ADDED
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import { waitUntil } from '@vercel/functions';
|
|
2
|
+
import { FatalError, RetryableError, WorkflowAPIError, WorkflowRunCancelledError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, } from '@workflow/errors';
|
|
3
|
+
import { WorkflowSuspension } from './global.js';
|
|
4
|
+
import { runtimeLogger } from './logger.js';
|
|
5
|
+
import { getStepFunction } from './private.js';
|
|
6
|
+
import { getWorld, getWorldHandlers } from './runtime/world.js';
|
|
7
|
+
import { StepInvokePayloadSchema, WorkflowInvokePayloadSchema, } from './schemas.js';
|
|
8
|
+
import { dehydrateStepArguments, dehydrateStepReturnValue, getExternalRevivers, hydrateStepArguments, hydrateWorkflowReturnValue, } from './serialization.js';
|
|
9
|
+
// TODO: move step handler out to a separate file
|
|
10
|
+
import { contextStorage } from './step/context-storage.js';
|
|
11
|
+
import * as Attribute from './telemetry/semantic-conventions.js';
|
|
12
|
+
import { serializeTraceCarrier, trace, withTraceContext } from './telemetry.js';
|
|
13
|
+
import { getErrorName, getErrorStack, isInstanceOf } from './types.js';
|
|
14
|
+
import { buildWorkflowSuspensionMessage, getWorkflowRunStreamId, } from './util.js';
|
|
15
|
+
import { runWorkflow } from './workflow.js';
|
|
16
|
+
export { WorkflowSuspension } from './global.js';
|
|
17
|
+
export { getHookByToken, resumeHook, resumeWebhook, } from './runtime/resume-hook.js';
|
|
18
|
+
export { start } from './runtime/start.js';
|
|
19
|
+
export { createWorld, getWorld, getWorldHandlers, setWorld, } from './runtime/world.js';
|
|
20
|
+
/**
|
|
21
|
+
* A handler class for a workflow run.
|
|
22
|
+
*/
|
|
23
|
+
export class Run {
|
|
24
|
+
/**
|
|
25
|
+
* The ID of the workflow run.
|
|
26
|
+
*/
|
|
27
|
+
runId;
|
|
28
|
+
/**
|
|
29
|
+
* The world object.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
world;
|
|
33
|
+
constructor(runId) {
|
|
34
|
+
this.runId = runId;
|
|
35
|
+
this.world = getWorld();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Cancels the workflow run.
|
|
39
|
+
*/
|
|
40
|
+
async cancel() {
|
|
41
|
+
await this.world.runs.cancel(this.runId);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The status of the workflow run.
|
|
45
|
+
*/
|
|
46
|
+
get status() {
|
|
47
|
+
return this.world.runs.get(this.runId).then((run) => run.status);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The return value of the workflow run.
|
|
51
|
+
* Polls the workflow return value until it is completed.
|
|
52
|
+
*/
|
|
53
|
+
get returnValue() {
|
|
54
|
+
return this.pollReturnValue();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The name of the workflow.
|
|
58
|
+
*/
|
|
59
|
+
get workflowName() {
|
|
60
|
+
return this.world.runs.get(this.runId).then((run) => run.workflowName);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The timestamp when the workflow run was created.
|
|
64
|
+
*/
|
|
65
|
+
get createdAt() {
|
|
66
|
+
return this.world.runs.get(this.runId).then((run) => run.createdAt);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The timestamp when the workflow run started execution.
|
|
70
|
+
* Returns undefined if the workflow has not started yet.
|
|
71
|
+
*/
|
|
72
|
+
get startedAt() {
|
|
73
|
+
return this.world.runs.get(this.runId).then((run) => run.startedAt);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The timestamp when the workflow run completed.
|
|
77
|
+
* Returns undefined if the workflow has not completed yet.
|
|
78
|
+
*/
|
|
79
|
+
get completedAt() {
|
|
80
|
+
return this.world.runs.get(this.runId).then((run) => run.completedAt);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The readable stream of the workflow run.
|
|
84
|
+
*/
|
|
85
|
+
get readable() {
|
|
86
|
+
return this.getReadable();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves the workflow run's default readable stream, which reads chunks
|
|
90
|
+
* written to the corresponding writable stream {@link getWritable}.
|
|
91
|
+
*
|
|
92
|
+
* @param options - The options for the readable stream.
|
|
93
|
+
* @returns The `ReadableStream` for the workflow run.
|
|
94
|
+
*/
|
|
95
|
+
getReadable(options = {}) {
|
|
96
|
+
const { ops = [], global = globalThis, startIndex, namespace } = options;
|
|
97
|
+
const name = getWorkflowRunStreamId(this.runId, namespace);
|
|
98
|
+
return getExternalRevivers(global, ops).ReadableStream({
|
|
99
|
+
name,
|
|
100
|
+
startIndex,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Polls the workflow return value every 1 second until it is completed.
|
|
105
|
+
* @internal
|
|
106
|
+
* @returns The workflow return value.
|
|
107
|
+
*/
|
|
108
|
+
async pollReturnValue() {
|
|
109
|
+
while (true) {
|
|
110
|
+
try {
|
|
111
|
+
const run = await this.world.runs.get(this.runId);
|
|
112
|
+
if (run.status === 'completed') {
|
|
113
|
+
return hydrateWorkflowReturnValue(run.output, [], globalThis);
|
|
114
|
+
}
|
|
115
|
+
if (run.status === 'cancelled') {
|
|
116
|
+
throw new WorkflowRunCancelledError(this.runId);
|
|
117
|
+
}
|
|
118
|
+
if (run.status === 'failed') {
|
|
119
|
+
throw new WorkflowRunFailedError(this.runId, run.error ?? 'Unknown error');
|
|
120
|
+
}
|
|
121
|
+
throw new WorkflowRunNotCompletedError(this.runId, run.status);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (error instanceof WorkflowRunNotCompletedError) {
|
|
125
|
+
await new Promise((resolve) => setTimeout(resolve, 1_000));
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Retrieves a `Run` object for a given run ID.
|
|
135
|
+
*
|
|
136
|
+
* @param runId - The workflow run ID obtained from {@link start}.
|
|
137
|
+
* @returns A `Run` object.
|
|
138
|
+
* @throws WorkflowRunNotFoundError if the run ID is not found.
|
|
139
|
+
*/
|
|
140
|
+
export function getRun(runId) {
|
|
141
|
+
return new Run(runId);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Loads all workflow run events by iterating through all pages of paginated results.
|
|
145
|
+
* This ensures that *all* events are loaded into memory before running the workflow.
|
|
146
|
+
* Events must be in chronological order (ascending) for proper workflow replay.
|
|
147
|
+
*/
|
|
148
|
+
async function getAllWorkflowRunEvents(runId) {
|
|
149
|
+
const allEvents = [];
|
|
150
|
+
let cursor = null;
|
|
151
|
+
let hasMore = true;
|
|
152
|
+
const world = getWorld();
|
|
153
|
+
while (hasMore) {
|
|
154
|
+
const response = await world.events.list({
|
|
155
|
+
runId,
|
|
156
|
+
pagination: {
|
|
157
|
+
sortOrder: 'asc', // Required: events must be in chronological order for replay
|
|
158
|
+
cursor: cursor ?? undefined,
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
allEvents.push(...response.data);
|
|
162
|
+
hasMore = response.hasMore;
|
|
163
|
+
cursor = response.cursor;
|
|
164
|
+
}
|
|
165
|
+
return allEvents;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Function that creates a single route which handles any workflow execution
|
|
169
|
+
* request and routes to the appropriate workflow function.
|
|
170
|
+
*
|
|
171
|
+
* @param workflowCode - The workflow bundle code containing all the workflow
|
|
172
|
+
* functions at the top level.
|
|
173
|
+
* @returns A function that can be used as a Vercel API route.
|
|
174
|
+
*/
|
|
175
|
+
export function workflowEntrypoint(workflowCode) {
|
|
176
|
+
return getWorldHandlers().createQueueHandler('__wkf_workflow_', async (message_, metadata) => {
|
|
177
|
+
const { runId, traceCarrier: traceContext } = WorkflowInvokePayloadSchema.parse(message_);
|
|
178
|
+
// Extract the workflow name from the topic name
|
|
179
|
+
const workflowName = metadata.queueName.slice('__wkf_workflow_'.length);
|
|
180
|
+
// Invoke user workflow within the propagated trace context
|
|
181
|
+
return await withTraceContext(traceContext, async () => {
|
|
182
|
+
const world = getWorld();
|
|
183
|
+
return trace(`WORKFLOW ${workflowName}`, async (span) => {
|
|
184
|
+
span?.setAttributes({
|
|
185
|
+
...Attribute.WorkflowName(workflowName),
|
|
186
|
+
...Attribute.WorkflowOperation('execute'),
|
|
187
|
+
...Attribute.QueueName(metadata.queueName),
|
|
188
|
+
});
|
|
189
|
+
// TODO: validate `workflowName` exists before consuming message?
|
|
190
|
+
span?.setAttributes({
|
|
191
|
+
...Attribute.WorkflowRunId(runId),
|
|
192
|
+
...Attribute.WorkflowTracePropagated(!!traceContext),
|
|
193
|
+
});
|
|
194
|
+
let workflowStartedAt = -1;
|
|
195
|
+
try {
|
|
196
|
+
let workflowRun = await world.runs.get(runId);
|
|
197
|
+
if (workflowRun.status === 'pending') {
|
|
198
|
+
workflowRun = await world.runs.update(runId, {
|
|
199
|
+
// This sets the `startedAt` timestamp at the database level
|
|
200
|
+
status: 'running',
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
// At this point, the workflow is "running" and `startedAt` should
|
|
204
|
+
// definitely be set.
|
|
205
|
+
if (!workflowRun.startedAt) {
|
|
206
|
+
throw new Error(`Workflow run "${runId}" has no "startedAt" timestamp`);
|
|
207
|
+
}
|
|
208
|
+
workflowStartedAt = +workflowRun.startedAt;
|
|
209
|
+
span?.setAttributes({
|
|
210
|
+
...Attribute.WorkflowRunStatus(workflowRun.status),
|
|
211
|
+
...Attribute.WorkflowStartedAt(workflowStartedAt),
|
|
212
|
+
});
|
|
213
|
+
if (workflowRun.status !== 'running') {
|
|
214
|
+
// Workflow has already completed or failed, so we can skip it
|
|
215
|
+
console.warn(`Workflow "${runId}" has status "${workflowRun.status}", skipping`);
|
|
216
|
+
// TODO: for `cancel`, we actually want to propagate a WorkflowCancelled event
|
|
217
|
+
// inside the workflow context so the user can gracefully exit. this is SIGTERM
|
|
218
|
+
// TODO: furthermore, there should be a timeout or a way to force cancel SIGKILL
|
|
219
|
+
// so that we actually exit here without replaying the workflow at all, in the case
|
|
220
|
+
// the replaying the workflow is itself failing.
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
// Load all events into memory before running
|
|
224
|
+
const events = await getAllWorkflowRunEvents(workflowRun.runId);
|
|
225
|
+
const result = await runWorkflow(workflowCode, workflowRun, events);
|
|
226
|
+
// Update the workflow run with the result
|
|
227
|
+
await world.runs.update(runId, {
|
|
228
|
+
status: 'completed',
|
|
229
|
+
output: result,
|
|
230
|
+
});
|
|
231
|
+
span?.setAttributes({
|
|
232
|
+
...Attribute.WorkflowRunStatus('completed'),
|
|
233
|
+
...Attribute.WorkflowEventsCount(events.length),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
if (isInstanceOf(err, WorkflowSuspension)) {
|
|
238
|
+
const suspensionMessage = buildWorkflowSuspensionMessage(runId, err.stepCount, err.hookCount);
|
|
239
|
+
if (suspensionMessage) {
|
|
240
|
+
// Note: suspensionMessage logged only in debug mode to avoid production noise
|
|
241
|
+
// console.debug(suspensionMessage);
|
|
242
|
+
}
|
|
243
|
+
// Process each operation in the queue (steps and hooks)
|
|
244
|
+
for (const queueItem of err.steps) {
|
|
245
|
+
if (queueItem.type === 'step') {
|
|
246
|
+
// Handle step operations
|
|
247
|
+
const ops = [];
|
|
248
|
+
const dehydratedArgs = dehydrateStepArguments(queueItem.args, err.globalThis);
|
|
249
|
+
try {
|
|
250
|
+
const step = await world.steps.create(runId, {
|
|
251
|
+
stepId: queueItem.correlationId,
|
|
252
|
+
stepName: queueItem.stepName,
|
|
253
|
+
input: dehydratedArgs,
|
|
254
|
+
});
|
|
255
|
+
waitUntil(Promise.all(ops));
|
|
256
|
+
await world.queue(`__wkf_step_${queueItem.stepName}`, {
|
|
257
|
+
workflowName,
|
|
258
|
+
workflowRunId: runId,
|
|
259
|
+
workflowStartedAt,
|
|
260
|
+
stepId: step.stepId,
|
|
261
|
+
traceCarrier: await serializeTraceCarrier(),
|
|
262
|
+
}, {
|
|
263
|
+
idempotencyKey: queueItem.correlationId,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
catch (err) {
|
|
267
|
+
if (isInstanceOf(err, WorkflowAPIError) &&
|
|
268
|
+
err.status === 409) {
|
|
269
|
+
// Step already exists, so we can skip it
|
|
270
|
+
console.warn(`Step "${queueItem.stepName}" with correlation ID "${queueItem.correlationId}" already exists, skipping: ${err.message}`);
|
|
271
|
+
continue;
|
|
272
|
+
}
|
|
273
|
+
throw err;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
else if (queueItem.type === 'hook') {
|
|
277
|
+
// Handle hook operations
|
|
278
|
+
try {
|
|
279
|
+
// Create hook in database
|
|
280
|
+
const hookMetadata = typeof queueItem.metadata === 'undefined'
|
|
281
|
+
? undefined
|
|
282
|
+
: dehydrateStepArguments(queueItem.metadata, err.globalThis);
|
|
283
|
+
await world.hooks.create(runId, {
|
|
284
|
+
hookId: queueItem.correlationId,
|
|
285
|
+
token: queueItem.token,
|
|
286
|
+
metadata: hookMetadata,
|
|
287
|
+
});
|
|
288
|
+
// Create hook_created event in event log
|
|
289
|
+
await world.events.create(runId, {
|
|
290
|
+
eventType: 'hook_created',
|
|
291
|
+
correlationId: queueItem.correlationId,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
if (isInstanceOf(err, WorkflowAPIError)) {
|
|
296
|
+
if (err.status === 409) {
|
|
297
|
+
// Hook already exists (duplicate hook_id constraint), so we can skip it
|
|
298
|
+
console.warn(`Hook with correlation ID "${queueItem.correlationId}" already exists, skipping: ${err.message}`);
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
else if (err.status === 410) {
|
|
302
|
+
// Workflow has already completed, so no-op
|
|
303
|
+
console.warn(`Workflow run "${runId}" has already completed, skipping hook "${queueItem.correlationId}": ${err.message}`);
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
throw err;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
span?.setAttributes({
|
|
312
|
+
...Attribute.WorkflowRunStatus('pending_steps'),
|
|
313
|
+
...Attribute.WorkflowStepsCreated(err.steps.length),
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
const errorName = getErrorName(err);
|
|
318
|
+
const errorStack = getErrorStack(err);
|
|
319
|
+
console.error(`${errorName} while running "${runId}" workflow:\n\n${errorStack}`);
|
|
320
|
+
await world.runs.update(runId, {
|
|
321
|
+
status: 'failed',
|
|
322
|
+
error: String(err),
|
|
323
|
+
// TODO: include error codes when we define them
|
|
324
|
+
// TODO: serialize/include the error name and stack?
|
|
325
|
+
});
|
|
326
|
+
span?.setAttributes({
|
|
327
|
+
...Attribute.WorkflowRunStatus('failed'),
|
|
328
|
+
...Attribute.WorkflowErrorName(errorName),
|
|
329
|
+
...Attribute.WorkflowErrorMessage(String(err)),
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}); // End withTraceContext
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* A single route that handles any step execution request and routes to the
|
|
339
|
+
* appropriate step function. We may eventually want to create different bundles
|
|
340
|
+
* for each step, this is temporary.
|
|
341
|
+
*/
|
|
342
|
+
export const stepEntrypoint =
|
|
343
|
+
/* @__PURE__ */ getWorldHandlers().createQueueHandler('__wkf_step_', async (message_, metadata) => {
|
|
344
|
+
const { workflowName, workflowRunId, workflowStartedAt, stepId, traceCarrier: traceContext, } = StepInvokePayloadSchema.parse(message_);
|
|
345
|
+
// Execute step within the propagated trace context
|
|
346
|
+
return await withTraceContext(traceContext, async () => {
|
|
347
|
+
// Extract the step name from the topic name
|
|
348
|
+
const stepName = metadata.queueName.slice('__wkf_step_'.length);
|
|
349
|
+
const world = getWorld();
|
|
350
|
+
return trace(`STEP ${stepName}`, async (span) => {
|
|
351
|
+
span?.setAttributes({
|
|
352
|
+
...Attribute.StepName(stepName),
|
|
353
|
+
...Attribute.StepAttempt(metadata.attempt),
|
|
354
|
+
...Attribute.QueueName(metadata.queueName),
|
|
355
|
+
});
|
|
356
|
+
const stepFn = getStepFunction(stepName);
|
|
357
|
+
if (!stepFn) {
|
|
358
|
+
throw new Error(`Step "${stepName}" not found`);
|
|
359
|
+
}
|
|
360
|
+
if (typeof stepFn !== 'function') {
|
|
361
|
+
throw new Error(`Step "${stepName}" is not a function (got ${typeof stepFn})`);
|
|
362
|
+
}
|
|
363
|
+
span?.setAttributes({
|
|
364
|
+
...Attribute.WorkflowName(workflowName),
|
|
365
|
+
...Attribute.WorkflowRunId(workflowRunId),
|
|
366
|
+
...Attribute.StepId(stepId),
|
|
367
|
+
...Attribute.StepMaxRetries(stepFn.maxRetries ?? 3),
|
|
368
|
+
...Attribute.StepTracePropagated(!!traceContext),
|
|
369
|
+
});
|
|
370
|
+
let step = await world.steps.get(workflowRunId, stepId);
|
|
371
|
+
runtimeLogger.debug('Step execution details', {
|
|
372
|
+
stepName,
|
|
373
|
+
stepId: step.stepId,
|
|
374
|
+
status: step.status,
|
|
375
|
+
attempt: step.attempt,
|
|
376
|
+
});
|
|
377
|
+
span?.setAttributes({
|
|
378
|
+
...Attribute.StepStatus(step.status),
|
|
379
|
+
});
|
|
380
|
+
let result;
|
|
381
|
+
const attempt = step.attempt + 1;
|
|
382
|
+
try {
|
|
383
|
+
if (step.status !== 'pending') {
|
|
384
|
+
// We should only be running the step if it's pending
|
|
385
|
+
// (initial state, or state set on re-try), so the step has been
|
|
386
|
+
// invoked erroneously.
|
|
387
|
+
console.error(`[Workflows] "${workflowRunId}" - Step invoked erroneously, expected status "pending", got "${step.status}" instead, skipping execution`);
|
|
388
|
+
span?.setAttributes({
|
|
389
|
+
...Attribute.StepSkipped(true),
|
|
390
|
+
...Attribute.StepSkipReason(step.status),
|
|
391
|
+
});
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
await world.events.create(workflowRunId, {
|
|
395
|
+
eventType: 'step_started', // TODO: Replace with 'step_retrying'
|
|
396
|
+
correlationId: stepId,
|
|
397
|
+
});
|
|
398
|
+
step = await world.steps.update(workflowRunId, stepId, {
|
|
399
|
+
attempt,
|
|
400
|
+
status: 'running',
|
|
401
|
+
});
|
|
402
|
+
if (!step.startedAt) {
|
|
403
|
+
throw new WorkflowRuntimeError(`Step "${stepId}" has no "startedAt" timestamp`);
|
|
404
|
+
}
|
|
405
|
+
// Hydrate the step input arguments
|
|
406
|
+
const ops = [];
|
|
407
|
+
const args = hydrateStepArguments(step.input, ops);
|
|
408
|
+
span?.setAttributes({
|
|
409
|
+
...Attribute.StepArgumentsCount(args.length),
|
|
410
|
+
});
|
|
411
|
+
result = await contextStorage.run({
|
|
412
|
+
stepMetadata: {
|
|
413
|
+
stepId,
|
|
414
|
+
stepStartedAt: new Date(+step.startedAt),
|
|
415
|
+
attempt,
|
|
416
|
+
},
|
|
417
|
+
workflowMetadata: {
|
|
418
|
+
workflowRunId,
|
|
419
|
+
workflowStartedAt: new Date(+workflowStartedAt),
|
|
420
|
+
// TODO: there should be a getUrl method on the world interface itself. This
|
|
421
|
+
// solution only works for vercel + embedded worlds.
|
|
422
|
+
url: process.env.VERCEL_URL
|
|
423
|
+
? `https://${process.env.VERCEL_URL}`
|
|
424
|
+
: `http://localhost:${process.env.PORT || 3000}`,
|
|
425
|
+
},
|
|
426
|
+
}, () => stepFn(...args));
|
|
427
|
+
result = dehydrateStepReturnValue(result, ops);
|
|
428
|
+
waitUntil(Promise.all(ops));
|
|
429
|
+
// Update the event log with the step result
|
|
430
|
+
await world.events.create(workflowRunId, {
|
|
431
|
+
eventType: 'step_completed',
|
|
432
|
+
correlationId: stepId,
|
|
433
|
+
eventData: {
|
|
434
|
+
result: result,
|
|
435
|
+
},
|
|
436
|
+
});
|
|
437
|
+
await world.steps.update(workflowRunId, stepId, {
|
|
438
|
+
status: 'completed',
|
|
439
|
+
output: result,
|
|
440
|
+
});
|
|
441
|
+
span?.setAttributes({
|
|
442
|
+
...Attribute.StepStatus('completed'),
|
|
443
|
+
...Attribute.StepResultType(typeof result),
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
catch (err) {
|
|
447
|
+
span?.setAttributes({
|
|
448
|
+
...Attribute.StepErrorName(getErrorName(err)),
|
|
449
|
+
...Attribute.StepErrorMessage(String(err)),
|
|
450
|
+
});
|
|
451
|
+
if (isInstanceOf(err, WorkflowAPIError)) {
|
|
452
|
+
if (err.status === 410) {
|
|
453
|
+
// Workflow has already completed, so no-op
|
|
454
|
+
console.warn(`Workflow run "${workflowRunId}" has already completed, skipping step "${stepId}": ${err.message}`);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (isInstanceOf(err, FatalError)) {
|
|
459
|
+
const stackLines = getErrorStack(err).split('\n').slice(0, 4);
|
|
460
|
+
console.error(`[Workflows] "${workflowRunId}" - Encountered \`FatalError\` while executing step "${stepName}":\n > ${stackLines.join('\n > ')}\n\nBubbling up error to parent workflow`);
|
|
461
|
+
// Fatal error - store the error in the event log and re-invoke the workflow
|
|
462
|
+
await world.events.create(workflowRunId, {
|
|
463
|
+
eventType: 'step_failed',
|
|
464
|
+
correlationId: stepId,
|
|
465
|
+
eventData: {
|
|
466
|
+
error: String(err),
|
|
467
|
+
stack: err.stack,
|
|
468
|
+
fatal: true,
|
|
469
|
+
},
|
|
470
|
+
});
|
|
471
|
+
await world.steps.update(workflowRunId, stepId, {
|
|
472
|
+
status: 'failed',
|
|
473
|
+
error: String(err),
|
|
474
|
+
// TODO: include error codes when we define them
|
|
475
|
+
// TODO: serialize/include the error name and stack?
|
|
476
|
+
});
|
|
477
|
+
span?.setAttributes({
|
|
478
|
+
...Attribute.StepStatus('failed'),
|
|
479
|
+
...Attribute.StepFatalError(true),
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
else {
|
|
483
|
+
const maxRetries = stepFn.maxRetries ?? 3;
|
|
484
|
+
span?.setAttributes({
|
|
485
|
+
...Attribute.StepAttempt(attempt),
|
|
486
|
+
...Attribute.StepMaxRetries(maxRetries),
|
|
487
|
+
});
|
|
488
|
+
if (attempt >= maxRetries) {
|
|
489
|
+
// Max retries reached
|
|
490
|
+
const stackLines = getErrorStack(err).split('\n').slice(0, 4);
|
|
491
|
+
console.error(`[Workflows] "${workflowRunId}" - Encountered \`Error\` while executing step "${stepName}" (attempt ${attempt}):\n > ${stackLines.join('\n > ')}\n\n Max retries reached\n Bubbling error to parent workflow`);
|
|
492
|
+
const errorMessage = `Step "${stepName}" failed after max retries: ${String(err)}`;
|
|
493
|
+
await world.events.create(workflowRunId, {
|
|
494
|
+
eventType: 'step_failed',
|
|
495
|
+
correlationId: stepId,
|
|
496
|
+
eventData: {
|
|
497
|
+
error: errorMessage,
|
|
498
|
+
stack: getErrorStack(err),
|
|
499
|
+
fatal: true,
|
|
500
|
+
},
|
|
501
|
+
});
|
|
502
|
+
await world.steps.update(workflowRunId, stepId, {
|
|
503
|
+
status: 'failed',
|
|
504
|
+
error: errorMessage,
|
|
505
|
+
});
|
|
506
|
+
span?.setAttributes({
|
|
507
|
+
...Attribute.StepStatus('failed'),
|
|
508
|
+
...Attribute.StepRetryExhausted(true),
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
// Not at max retries yet - log as a retryable error
|
|
513
|
+
if (isInstanceOf(err, RetryableError)) {
|
|
514
|
+
console.warn(`[Workflows] "${workflowRunId}" - Encountered \`RetryableError\` while executing step "${stepName}" (attempt ${attempt}):\n > ${String(err.message)}\n\n This step has failed but will be retried`);
|
|
515
|
+
}
|
|
516
|
+
else {
|
|
517
|
+
const stackLines = getErrorStack(err).split('\n').slice(0, 4);
|
|
518
|
+
console.error(`[Workflows] "${workflowRunId}" - Encountered \`Error\` while executing step "${stepName}" (attempt ${attempt}):\n > ${stackLines.join('\n > ')}\n\n This step has failed but will be retried`);
|
|
519
|
+
}
|
|
520
|
+
await world.events.create(workflowRunId, {
|
|
521
|
+
eventType: 'step_failed',
|
|
522
|
+
correlationId: stepId,
|
|
523
|
+
eventData: {
|
|
524
|
+
error: String(err),
|
|
525
|
+
stack: getErrorStack(err),
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
await world.steps.update(workflowRunId, stepId, {
|
|
529
|
+
status: 'pending', // TODO: Should be "retrying" once we have that status
|
|
530
|
+
});
|
|
531
|
+
const timeoutSeconds = Math.max(1, isInstanceOf(err, RetryableError)
|
|
532
|
+
? Math.floor((+err.retryAfter.getTime() - Date.now()) / 1000)
|
|
533
|
+
: 1);
|
|
534
|
+
span?.setAttributes({
|
|
535
|
+
...Attribute.StepRetryTimeoutSeconds(timeoutSeconds),
|
|
536
|
+
...Attribute.StepRetryWillRetry(true),
|
|
537
|
+
});
|
|
538
|
+
// It's a retryable error - so have the queue keep the message visible
|
|
539
|
+
// so that it gets retried.
|
|
540
|
+
return { timeoutSeconds };
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
await world.queue(`__wkf_workflow_${workflowName}`, {
|
|
545
|
+
runId: workflowRunId,
|
|
546
|
+
traceCarrier: await serializeTraceCarrier(),
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
});
|
|
550
|
+
});
|
|
551
|
+
// this is a no-op placeholder as the client is
|
|
552
|
+
// expecting this to be present but we aren't actually using it
|
|
553
|
+
export function runStep() { }
|
|
554
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EACL,UAAU,EACV,cAAc,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aAAa,CAAC,GAAG,CAAC;6BAC1B;yBACF,CAAC,CAAC;wBACH,MAAM,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE;4BAC9C,MAAM,EAAE,SAAS,EAAE,sDAAsD;yBAC1E,CAAC,CAAC;wBACH,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAC7B,CAAC,EACD,YAAY,CAAC,GAAG,EAAE,cAAc,CAAC;4BAC/B,CAAC,CAAC,IAAI,CAAC,KAAK,CACR,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAChD;4BACH,CAAC,CAAC,CAAC,CACN,CAAC;wBAEF,IAAI,EAAE,aAAa,CAAC;4BAClB,GAAG,SAAS,CAAC,uBAAuB,CAAC,cAAc,CAAC;4BACpD,GAAG,SAAS,CAAC,kBAAkB,CAAC,IAAI,CAAC;yBACtC,CAAC,CAAC;wBAEH,sEAAsE;wBACtE,2BAA2B;wBAC3B,OAAO,EAAE,cAAc,EAAE,CAAC;oBAC5B,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,KAAK,CAAC,KAAK,CAAC,kBAAkB,YAAY,EAAE,EAAE;gBAClD,KAAK,EAAE,aAAa;gBACpB,YAAY,EAAE,MAAM,qBAAqB,EAAE;aACZ,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEJ,+CAA+C;AAC/C,+DAA+D;AAC/D,MAAM,UAAU,OAAO,KAAI,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const WorkflowInvokePayloadSchema: z.ZodObject<{
|
|
3
|
+
runId: z.ZodString;
|
|
4
|
+
traceCarrier: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const StepInvokePayloadSchema: z.ZodObject<{
|
|
7
|
+
workflowName: z.ZodString;
|
|
8
|
+
workflowRunId: z.ZodString;
|
|
9
|
+
workflowStartedAt: z.ZodNumber;
|
|
10
|
+
stepId: z.ZodString;
|
|
11
|
+
traceCarrier: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type WorkflowInvokePayload = z.infer<typeof WorkflowInvokePayloadSchema>;
|
|
14
|
+
export type StepInvokePayload = z.infer<typeof StepInvokePayloadSchema>;
|
|
15
|
+
/**
|
|
16
|
+
* A serializable value:
|
|
17
|
+
* Any valid JSON object is serializable
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* // any valid JSON object is serializable
|
|
23
|
+
* const anyJson: Serializable = { foo: "bar" };
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type Serializable = string | number | boolean | null | undefined | Serializable[] | {
|
|
27
|
+
[key: string]: Serializable;
|
|
28
|
+
} | ArrayBuffer | BigInt64Array | BigUint64Array | Date | Float32Array | Float64Array | Headers | Int8Array | Int16Array | Int32Array | Map<Serializable, Serializable> | ReadableStream<Uint8Array> | RegExp | Response | Set<Serializable> | URL | URLSearchParams | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array | WritableStream<Uint8Array>;
|
|
29
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,2BAA2B;;;iBAGtC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;iBAMlC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAEpB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,YAAY,EAAE,GACd;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,CAAA;CAAE,GAG/B,WAAW,GACX,aAAa,GACb,cAAc,GACd,IAAI,GACJ,YAAY,GACZ,YAAY,GACZ,OAAO,GACP,SAAS,GACT,UAAU,GACV,UAAU,GACV,GAAG,CAAC,YAAY,EAAE,YAAY,CAAC,GAC/B,cAAc,CAAC,UAAU,CAAC,GAC1B,MAAM,GACN,QAAQ,GACR,GAAG,CAAC,YAAY,CAAC,GACjB,GAAG,GACH,eAAe,GACf,UAAU,GACV,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,cAAc,CAAC,UAAU,CAAC,CAAC"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// OpenTelemetry trace context for distributed tracing
|
|
3
|
+
const TraceCarrierSchema = z.record(z.string(), z.string());
|
|
4
|
+
export const WorkflowInvokePayloadSchema = z.object({
|
|
5
|
+
runId: z.string(),
|
|
6
|
+
traceCarrier: TraceCarrierSchema.optional(),
|
|
7
|
+
});
|
|
8
|
+
export const StepInvokePayloadSchema = z.object({
|
|
9
|
+
workflowName: z.string(),
|
|
10
|
+
workflowRunId: z.string(),
|
|
11
|
+
workflowStartedAt: z.number(),
|
|
12
|
+
stepId: z.string(),
|
|
13
|
+
traceCarrier: TraceCarrierSchema.optional(),
|
|
14
|
+
});
|
|
15
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sDAAsD;AACtD,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,YAAY,EAAE,kBAAkB,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,YAAY,EAAE,kBAAkB,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC"}
|