@workflow/world-testing 5.0.0-beta.20 → 5.0.0-beta.22
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.
|
@@ -16000,6 +16000,7 @@ var init_events2 = __esm({
|
|
|
16000
16000
|
runId: external_exports2.string(),
|
|
16001
16001
|
eventId: external_exports2.string(),
|
|
16002
16002
|
createdAt: external_exports2.coerce.date(),
|
|
16003
|
+
occurredAt: external_exports2.coerce.date().optional(),
|
|
16003
16004
|
specVersion: external_exports2.number().optional()
|
|
16004
16005
|
}));
|
|
16005
16006
|
}
|
|
@@ -19192,7 +19193,7 @@ var version4;
|
|
|
19192
19193
|
var init_version3 = __esm({
|
|
19193
19194
|
"../core/dist/version.js"() {
|
|
19194
19195
|
"use strict";
|
|
19195
|
-
version4 = "5.0.0-beta.
|
|
19196
|
+
version4 = "5.0.0-beta.22";
|
|
19196
19197
|
}
|
|
19197
19198
|
});
|
|
19198
19199
|
|
|
@@ -21663,18 +21664,23 @@ function createCreateAbortController(ctx) {
|
|
|
21663
21664
|
}
|
|
21664
21665
|
if (event.eventType === "hook_received") {
|
|
21665
21666
|
const rawPayload = event.eventData?.payload;
|
|
21667
|
+
ctx.pendingDeliveries++;
|
|
21666
21668
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
21667
21669
|
let reason;
|
|
21668
|
-
|
|
21669
|
-
|
|
21670
|
-
|
|
21671
|
-
|
|
21672
|
-
reason
|
|
21670
|
+
try {
|
|
21671
|
+
if (rawPayload !== void 0) {
|
|
21672
|
+
try {
|
|
21673
|
+
const hydrated = await hydrateStepReturnValue(rawPayload, ctx.runId, ctx.encryptionKey, ctx.globalThis);
|
|
21674
|
+
if (hydrated && typeof hydrated === "object" && "reason" in hydrated) {
|
|
21675
|
+
reason = hydrated.reason;
|
|
21676
|
+
}
|
|
21677
|
+
} catch {
|
|
21673
21678
|
}
|
|
21674
|
-
} catch {
|
|
21675
21679
|
}
|
|
21680
|
+
this.signal._setAborted(reason);
|
|
21681
|
+
} finally {
|
|
21682
|
+
ctx.pendingDeliveries--;
|
|
21676
21683
|
}
|
|
21677
|
-
this.signal._setAborted(reason);
|
|
21678
21684
|
});
|
|
21679
21685
|
ctx.invocationsQueue.delete(correlationId);
|
|
21680
21686
|
return EventConsumerResult2.Consumed;
|
|
@@ -25333,14 +25339,6 @@ function createReconnectingFramedStream2(runId, name, startIndex) {
|
|
|
25333
25339
|
}
|
|
25334
25340
|
__name(connect2, "connect");
|
|
25335
25341
|
async function reconnect() {
|
|
25336
|
-
reconnectCount++;
|
|
25337
|
-
totalReconnectCount++;
|
|
25338
|
-
if (reconnectCount > FRAMED_STREAM_MAX_RECONNECTS2) {
|
|
25339
|
-
throw new Error(`Stream "${name}" exceeded maximum reconnection attempts (${FRAMED_STREAM_MAX_RECONNECTS2})`);
|
|
25340
|
-
}
|
|
25341
|
-
if (totalReconnectCount > FRAMED_STREAM_MAX_TOTAL_RECONNECTS2) {
|
|
25342
|
-
throw new Error(`Stream "${name}" exceeded maximum total reconnection attempts (${FRAMED_STREAM_MAX_TOTAL_RECONNECTS2})`);
|
|
25343
|
-
}
|
|
25344
25342
|
if (reader) {
|
|
25345
25343
|
await reader.cancel().catch(() => {
|
|
25346
25344
|
});
|
|
@@ -25349,7 +25347,21 @@ function createReconnectingFramedStream2(runId, name, startIndex) {
|
|
|
25349
25347
|
currentStartIndex += consumedFrames;
|
|
25350
25348
|
consumedFrames = 0;
|
|
25351
25349
|
buffer3 = new Uint8Array(0);
|
|
25352
|
-
|
|
25350
|
+
for (; ; ) {
|
|
25351
|
+
reconnectCount++;
|
|
25352
|
+
totalReconnectCount++;
|
|
25353
|
+
if (reconnectCount > FRAMED_STREAM_MAX_RECONNECTS2) {
|
|
25354
|
+
throw new Error(`Stream "${name}" exceeded maximum reconnection attempts (${FRAMED_STREAM_MAX_RECONNECTS2})`);
|
|
25355
|
+
}
|
|
25356
|
+
if (totalReconnectCount > FRAMED_STREAM_MAX_TOTAL_RECONNECTS2) {
|
|
25357
|
+
throw new Error(`Stream "${name}" exceeded maximum total reconnection attempts (${FRAMED_STREAM_MAX_TOTAL_RECONNECTS2})`);
|
|
25358
|
+
}
|
|
25359
|
+
try {
|
|
25360
|
+
await connect2();
|
|
25361
|
+
return;
|
|
25362
|
+
} catch {
|
|
25363
|
+
}
|
|
25364
|
+
}
|
|
25353
25365
|
}
|
|
25354
25366
|
__name(reconnect, "reconnect");
|
|
25355
25367
|
return new ReadableStream({
|
|
@@ -25798,7 +25810,7 @@ function reviveAbortController2(value, ops, runId) {
|
|
|
25798
25810
|
}
|
|
25799
25811
|
})());
|
|
25800
25812
|
if (value.hookToken) {
|
|
25801
|
-
|
|
25813
|
+
const hookResume = (async () => {
|
|
25802
25814
|
try {
|
|
25803
25815
|
const { resumeHook: resumeHookFn } = await Promise.resolve().then(() => (init_resume_hook2(), resume_hook_exports2));
|
|
25804
25816
|
await resumeHookFn(value.hookToken, {
|
|
@@ -25807,7 +25819,8 @@ function reviveAbortController2(value, ops, runId) {
|
|
|
25807
25819
|
});
|
|
25808
25820
|
} catch {
|
|
25809
25821
|
}
|
|
25810
|
-
})()
|
|
25822
|
+
})();
|
|
25823
|
+
ctx.preCompletionOps.push(hookResume);
|
|
25811
25824
|
}
|
|
25812
25825
|
}
|
|
25813
25826
|
};
|
|
@@ -72122,6 +72135,7 @@ var init_events = __esm2({
|
|
|
72122
72135
|
runId: external_exports.string(),
|
|
72123
72136
|
eventId: external_exports.string(),
|
|
72124
72137
|
createdAt: external_exports.coerce.date(),
|
|
72138
|
+
occurredAt: external_exports.coerce.date().optional(),
|
|
72125
72139
|
specVersion: external_exports.number().optional()
|
|
72126
72140
|
}));
|
|
72127
72141
|
}
|
|
@@ -79542,7 +79556,7 @@ var version2;
|
|
|
79542
79556
|
var init_version = __esm2({
|
|
79543
79557
|
"../core/dist/version.js"() {
|
|
79544
79558
|
"use strict";
|
|
79545
|
-
version2 = "5.0.0-beta.
|
|
79559
|
+
version2 = "5.0.0-beta.22";
|
|
79546
79560
|
}
|
|
79547
79561
|
});
|
|
79548
79562
|
function getWorkflowQueueName(workflowName, namespace) {
|
|
@@ -81287,14 +81301,6 @@ function createReconnectingFramedStream(runId, name, startIndex) {
|
|
|
81287
81301
|
__name(connect2, "connect");
|
|
81288
81302
|
__name2(connect2, "connect");
|
|
81289
81303
|
async function reconnect() {
|
|
81290
|
-
reconnectCount++;
|
|
81291
|
-
totalReconnectCount++;
|
|
81292
|
-
if (reconnectCount > FRAMED_STREAM_MAX_RECONNECTS) {
|
|
81293
|
-
throw new Error(`Stream "${name}" exceeded maximum reconnection attempts (${FRAMED_STREAM_MAX_RECONNECTS})`);
|
|
81294
|
-
}
|
|
81295
|
-
if (totalReconnectCount > FRAMED_STREAM_MAX_TOTAL_RECONNECTS) {
|
|
81296
|
-
throw new Error(`Stream "${name}" exceeded maximum total reconnection attempts (${FRAMED_STREAM_MAX_TOTAL_RECONNECTS})`);
|
|
81297
|
-
}
|
|
81298
81304
|
if (reader) {
|
|
81299
81305
|
await reader.cancel().catch(() => {
|
|
81300
81306
|
});
|
|
@@ -81303,7 +81309,21 @@ function createReconnectingFramedStream(runId, name, startIndex) {
|
|
|
81303
81309
|
currentStartIndex += consumedFrames;
|
|
81304
81310
|
consumedFrames = 0;
|
|
81305
81311
|
buffer22 = new Uint8Array(0);
|
|
81306
|
-
|
|
81312
|
+
for (; ; ) {
|
|
81313
|
+
reconnectCount++;
|
|
81314
|
+
totalReconnectCount++;
|
|
81315
|
+
if (reconnectCount > FRAMED_STREAM_MAX_RECONNECTS) {
|
|
81316
|
+
throw new Error(`Stream "${name}" exceeded maximum reconnection attempts (${FRAMED_STREAM_MAX_RECONNECTS})`);
|
|
81317
|
+
}
|
|
81318
|
+
if (totalReconnectCount > FRAMED_STREAM_MAX_TOTAL_RECONNECTS) {
|
|
81319
|
+
throw new Error(`Stream "${name}" exceeded maximum total reconnection attempts (${FRAMED_STREAM_MAX_TOTAL_RECONNECTS})`);
|
|
81320
|
+
}
|
|
81321
|
+
try {
|
|
81322
|
+
await connect2();
|
|
81323
|
+
return;
|
|
81324
|
+
} catch {
|
|
81325
|
+
}
|
|
81326
|
+
}
|
|
81307
81327
|
}
|
|
81308
81328
|
__name(reconnect, "reconnect");
|
|
81309
81329
|
__name2(reconnect, "reconnect");
|
|
@@ -81767,7 +81787,7 @@ function reviveAbortController(value, ops, runId) {
|
|
|
81767
81787
|
}
|
|
81768
81788
|
})());
|
|
81769
81789
|
if (value.hookToken) {
|
|
81770
|
-
|
|
81790
|
+
const hookResume = (async () => {
|
|
81771
81791
|
try {
|
|
81772
81792
|
const { resumeHook: resumeHookFn } = await Promise.resolve().then(() => (init_resume_hook(), resume_hook_exports));
|
|
81773
81793
|
await resumeHookFn(value.hookToken, {
|
|
@@ -81776,7 +81796,8 @@ function reviveAbortController(value, ops, runId) {
|
|
|
81776
81796
|
});
|
|
81777
81797
|
} catch {
|
|
81778
81798
|
}
|
|
81779
|
-
})()
|
|
81799
|
+
})();
|
|
81800
|
+
ctx.preCompletionOps.push(hookResume);
|
|
81780
81801
|
}
|
|
81781
81802
|
}
|
|
81782
81803
|
};
|
|
@@ -82772,7 +82793,7 @@ __name2(start, "start");
|
|
|
82772
82793
|
value: "start",
|
|
82773
82794
|
configurable: true
|
|
82774
82795
|
});
|
|
82775
|
-
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.
|
|
82796
|
+
})(start, "step//@workflow/core/runtime/start@5.0.0-beta.22//start");
|
|
82776
82797
|
function isRetryableStartError(err) {
|
|
82777
82798
|
if (ThrottleError.is(err)) return true;
|
|
82778
82799
|
if (WorkflowWorldError.is(err) && err.status && err.status >= 500) return true;
|
|
@@ -83106,7 +83127,7 @@ var Run = class _Run {
|
|
|
83106
83127
|
value: "wakeUp",
|
|
83107
83128
|
configurable: true
|
|
83108
83129
|
});
|
|
83109
|
-
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83130
|
+
})(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#wakeUp");
|
|
83110
83131
|
(function(__wf_fn, __wf_id) {
|
|
83111
83132
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83112
83133
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83115,7 +83136,7 @@ var Run = class _Run {
|
|
|
83115
83136
|
value: "cancel",
|
|
83116
83137
|
configurable: true
|
|
83117
83138
|
});
|
|
83118
|
-
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83139
|
+
})(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#cancel");
|
|
83119
83140
|
(function(__wf_fn, __wf_id) {
|
|
83120
83141
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83121
83142
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83124,7 +83145,7 @@ var Run = class _Run {
|
|
|
83124
83145
|
value: "getReadable",
|
|
83125
83146
|
configurable: true
|
|
83126
83147
|
});
|
|
83127
|
-
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83148
|
+
})(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#getReadable");
|
|
83128
83149
|
(function(__wf_fn, __wf_id) {
|
|
83129
83150
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83130
83151
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83133,7 +83154,7 @@ var Run = class _Run {
|
|
|
83133
83154
|
value: "exists",
|
|
83134
83155
|
configurable: true
|
|
83135
83156
|
});
|
|
83136
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83157
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#exists");
|
|
83137
83158
|
(function(__wf_fn, __wf_id) {
|
|
83138
83159
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83139
83160
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83142,7 +83163,7 @@ var Run = class _Run {
|
|
|
83142
83163
|
value: "status",
|
|
83143
83164
|
configurable: true
|
|
83144
83165
|
});
|
|
83145
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83166
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#status");
|
|
83146
83167
|
(function(__wf_fn, __wf_id) {
|
|
83147
83168
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83148
83169
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83151,7 +83172,7 @@ var Run = class _Run {
|
|
|
83151
83172
|
value: "returnValue",
|
|
83152
83173
|
configurable: true
|
|
83153
83174
|
});
|
|
83154
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83175
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#returnValue");
|
|
83155
83176
|
(function(__wf_fn, __wf_id) {
|
|
83156
83177
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83157
83178
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83160,7 +83181,7 @@ var Run = class _Run {
|
|
|
83160
83181
|
value: "workflowName",
|
|
83161
83182
|
configurable: true
|
|
83162
83183
|
});
|
|
83163
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83184
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#workflowName");
|
|
83164
83185
|
(function(__wf_fn, __wf_id) {
|
|
83165
83186
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83166
83187
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83169,7 +83190,7 @@ var Run = class _Run {
|
|
|
83169
83190
|
value: "createdAt",
|
|
83170
83191
|
configurable: true
|
|
83171
83192
|
});
|
|
83172
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83193
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#createdAt");
|
|
83173
83194
|
(function(__wf_fn, __wf_id) {
|
|
83174
83195
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83175
83196
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83178,7 +83199,7 @@ var Run = class _Run {
|
|
|
83178
83199
|
value: "startedAt",
|
|
83179
83200
|
configurable: true
|
|
83180
83201
|
});
|
|
83181
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83202
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#startedAt");
|
|
83182
83203
|
(function(__wf_fn, __wf_id) {
|
|
83183
83204
|
var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83184
83205
|
__wf_reg.set(__wf_id, __wf_fn);
|
|
@@ -83187,7 +83208,7 @@ var Run = class _Run {
|
|
|
83187
83208
|
value: "completedAt",
|
|
83188
83209
|
configurable: true
|
|
83189
83210
|
});
|
|
83190
|
-
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.
|
|
83211
|
+
})(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.22//Run#completedAt");
|
|
83191
83212
|
(function(__wf_cls, __wf_id) {
|
|
83192
83213
|
var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
|
|
83193
83214
|
__wf_reg.set(__wf_id, __wf_cls);
|
|
@@ -83197,7 +83218,7 @@ var Run = class _Run {
|
|
|
83197
83218
|
enumerable: false,
|
|
83198
83219
|
configurable: false
|
|
83199
83220
|
});
|
|
83200
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
83221
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.22//Run");
|
|
83201
83222
|
async function fetch2(...args) {
|
|
83202
83223
|
return globalThis.fetch(...args);
|
|
83203
83224
|
}
|
|
@@ -84039,6 +84060,20 @@ function isOptimisticInlineStartEnabled() {
|
|
|
84039
84060
|
return raw === "1" || raw.toLowerCase() === "true";
|
|
84040
84061
|
}
|
|
84041
84062
|
__name(isOptimisticInlineStartEnabled, "isOptimisticInlineStartEnabled");
|
|
84063
|
+
function isOptimisticInlineStartExplicitlyDisabled() {
|
|
84064
|
+
const raw = process.env.WORKFLOW_OPTIMISTIC_INLINE_START;
|
|
84065
|
+
if (raw === void 0 || raw === "")
|
|
84066
|
+
return false;
|
|
84067
|
+
return raw === "0" || raw.toLowerCase() === "false";
|
|
84068
|
+
}
|
|
84069
|
+
__name(isOptimisticInlineStartExplicitlyDisabled, "isOptimisticInlineStartExplicitlyDisabled");
|
|
84070
|
+
function isTurboEnabled() {
|
|
84071
|
+
const raw = process.env.WORKFLOW_TURBO;
|
|
84072
|
+
if (raw === void 0 || raw === "")
|
|
84073
|
+
return true;
|
|
84074
|
+
return !(raw === "0" || raw.toLowerCase() === "false");
|
|
84075
|
+
}
|
|
84076
|
+
__name(isTurboEnabled, "isTurboEnabled");
|
|
84042
84077
|
var REPLAY_DIVERGENCE_MAX_RETRIES = 3;
|
|
84043
84078
|
|
|
84044
84079
|
// ../core/dist/runtime.js
|
|
@@ -94266,7 +94301,7 @@ import os from "node:os";
|
|
|
94266
94301
|
import { inspect } from "node:util";
|
|
94267
94302
|
|
|
94268
94303
|
// ../world-vercel/dist/version.js
|
|
94269
|
-
var version5 = "5.0.0-beta.
|
|
94304
|
+
var version5 = "5.0.0-beta.20";
|
|
94270
94305
|
|
|
94271
94306
|
// ../world-vercel/dist/utils.js
|
|
94272
94307
|
var HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
|
|
@@ -94912,6 +94947,8 @@ function buildPostFrameMeta(input) {
|
|
|
94912
94947
|
meta5.correlationId = input.correlationId;
|
|
94913
94948
|
if (input.vercelId !== void 0)
|
|
94914
94949
|
meta5.vercelId = input.vercelId;
|
|
94950
|
+
if (input.occurredAt !== void 0)
|
|
94951
|
+
meta5.occurredAt = input.occurredAt;
|
|
94915
94952
|
if (input.remoteRefBehavior !== void 0) {
|
|
94916
94953
|
meta5.remoteRefBehavior = input.remoteRefBehavior;
|
|
94917
94954
|
}
|
|
@@ -94949,6 +94986,8 @@ function buildPostFrameMeta(input) {
|
|
|
94949
94986
|
}
|
|
94950
94987
|
if (input.sinceCursor !== void 0)
|
|
94951
94988
|
meta5.sinceCursor = input.sinceCursor;
|
|
94989
|
+
if (input.skipPreload !== void 0)
|
|
94990
|
+
meta5.skipPreload = input.skipPreload;
|
|
94952
94991
|
return meta5;
|
|
94953
94992
|
}
|
|
94954
94993
|
__name(buildPostFrameMeta, "buildPostFrameMeta");
|
|
@@ -95479,6 +95518,9 @@ function buildEventFromV4(decoded, payloadBody, resolveData) {
|
|
|
95479
95518
|
runId: decoded.runId,
|
|
95480
95519
|
eventType: decoded.eventType,
|
|
95481
95520
|
createdAt: decoded.createdAt instanceof Date ? decoded.createdAt : new Date(decoded.createdAt),
|
|
95521
|
+
...decoded.occurredAt !== void 0 ? {
|
|
95522
|
+
occurredAt: decoded.occurredAt instanceof Date ? decoded.occurredAt : new Date(decoded.occurredAt)
|
|
95523
|
+
} : {},
|
|
95482
95524
|
...decoded.correlationId ? { correlationId: decoded.correlationId } : {},
|
|
95483
95525
|
eventData,
|
|
95484
95526
|
...decoded.specVersion !== void 0 ? { specVersion: decoded.specVersion } : {}
|
|
@@ -95564,6 +95606,7 @@ async function createWorkflowRunEventInner(id, data, params, config4) {
|
|
|
95564
95606
|
specVersion: data.specVersion ?? 2,
|
|
95565
95607
|
...data.correlationId ? { correlationId: data.correlationId } : {},
|
|
95566
95608
|
...params?.requestId ? { vercelId: params.requestId } : {},
|
|
95609
|
+
occurredAt: params?.occurredAt ?? /* @__PURE__ */ new Date(),
|
|
95567
95610
|
// Opt-in inline-delta: forward the cursor the runtime held before
|
|
95568
95611
|
// this write so the server can return the authoritative event-log
|
|
95569
95612
|
// delta on the response (events/cursor/hasMore), letting the inline
|
|
@@ -95571,6 +95614,11 @@ async function createWorkflowRunEventInner(id, data, params, config4) {
|
|
|
95571
95614
|
// step_completed/step_failed; older servers ignore it and the runtime
|
|
95572
95615
|
// falls back to events.list.
|
|
95573
95616
|
...params?.sinceCursor ? { sinceCursor: params.sinceCursor } : {},
|
|
95617
|
+
// Run-started preload opt-out: turbo backgrounds run_started as a write
|
|
95618
|
+
// barrier only and never reads the preloaded log, so tell the server to
|
|
95619
|
+
// skip the list+resolve. The server only acts on it for run_started;
|
|
95620
|
+
// older servers ignore it and simply preload as before.
|
|
95621
|
+
...params?.skipPreload ? { skipPreload: true } : {},
|
|
95574
95622
|
remoteRefBehavior,
|
|
95575
95623
|
payload,
|
|
95576
95624
|
...meta5
|
|
@@ -95710,6 +95758,10 @@ function getStreamUrl(name, runId, httpConfig) {
|
|
|
95710
95758
|
return new URL(`${httpConfig.baseUrl}/v2/runs/${encodeURIComponent(runId)}/stream/${encodeURIComponent(name)}`);
|
|
95711
95759
|
}
|
|
95712
95760
|
__name(getStreamUrl, "getStreamUrl");
|
|
95761
|
+
function getStreamReadUrl(name, runId, httpConfig) {
|
|
95762
|
+
return new URL(`${httpConfig.baseUrl}/v3/runs/${encodeURIComponent(runId)}/stream/${encodeURIComponent(name)}`);
|
|
95763
|
+
}
|
|
95764
|
+
__name(getStreamReadUrl, "getStreamReadUrl");
|
|
95713
95765
|
function createStreamRequestError(operation, url3, response, text) {
|
|
95714
95766
|
const context2 = [`PUT ${url3.origin}${url3.pathname}`];
|
|
95715
95767
|
for (const header of ["x-vercel-id", "x-vercel-error"]) {
|
|
@@ -95809,7 +95861,7 @@ function createStreamer2(config4) {
|
|
|
95809
95861
|
},
|
|
95810
95862
|
async get(runId, name, startIndex) {
|
|
95811
95863
|
const httpConfig = await getHttpConfig(config4);
|
|
95812
|
-
const url3 =
|
|
95864
|
+
const url3 = getStreamReadUrl(name, runId, httpConfig);
|
|
95813
95865
|
if (typeof startIndex === "number") {
|
|
95814
95866
|
url3.searchParams.set("startIndex", String(startIndex));
|
|
95815
95867
|
}
|
|
@@ -96291,6 +96343,10 @@ async function executeStep(params) {
|
|
|
96291
96343
|
});
|
|
96292
96344
|
if (params.lazyStepInput !== void 0) {
|
|
96293
96345
|
try {
|
|
96346
|
+
if (params.runReadyBarrier) {
|
|
96347
|
+
await params.runReadyBarrier.catch(() => {
|
|
96348
|
+
});
|
|
96349
|
+
}
|
|
96294
96350
|
await world.events.create(workflowRunId, {
|
|
96295
96351
|
eventType: "step_started",
|
|
96296
96352
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
@@ -96369,7 +96425,7 @@ async function executeStep(params) {
|
|
|
96369
96425
|
}
|
|
96370
96426
|
return void 0;
|
|
96371
96427
|
}, "startErrorToResult");
|
|
96372
|
-
const optimisticStart = params.lazyStepInput !== void 0 && isOptimisticInlineStartEnabled();
|
|
96428
|
+
const optimisticStart = params.lazyStepInput !== void 0 && (isOptimisticInlineStartEnabled() || params.forceOptimisticStart === true && !isOptimisticInlineStartExplicitlyDisabled());
|
|
96373
96429
|
let step;
|
|
96374
96430
|
let optimisticStartSettled;
|
|
96375
96431
|
const reconcileOptimisticStart = /* @__PURE__ */ __name(async () => {
|
|
@@ -96384,12 +96440,12 @@ async function executeStep(params) {
|
|
|
96384
96440
|
return mapped;
|
|
96385
96441
|
}, "reconcileOptimisticStart");
|
|
96386
96442
|
if (optimisticStart) {
|
|
96387
|
-
const startedPromise = world.events.create(workflowRunId, {
|
|
96443
|
+
const startedPromise = (params.runReadyBarrier ?? Promise.resolve()).then(() => world.events.create(workflowRunId, {
|
|
96388
96444
|
eventType: "step_started",
|
|
96389
96445
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
96390
96446
|
correlationId: stepId,
|
|
96391
96447
|
eventData: { stepName, workflowName, input: params.lazyStepInput }
|
|
96392
|
-
});
|
|
96448
|
+
}));
|
|
96393
96449
|
optimisticStartSettled = startedPromise.then(() => ({ ok: true }), (err) => ({ ok: false, err }));
|
|
96394
96450
|
const now = /* @__PURE__ */ new Date();
|
|
96395
96451
|
step = {
|
|
@@ -96475,6 +96531,7 @@ async function executeStep(params) {
|
|
|
96475
96531
|
});
|
|
96476
96532
|
return { type: "failed" };
|
|
96477
96533
|
}
|
|
96534
|
+
const preCompletionOps = [];
|
|
96478
96535
|
try {
|
|
96479
96536
|
const attempt = step.attempt;
|
|
96480
96537
|
if (!step.startedAt) {
|
|
@@ -96514,6 +96571,7 @@ async function executeStep(params) {
|
|
|
96514
96571
|
},
|
|
96515
96572
|
workflowDeploymentId: params.workflowDeploymentId,
|
|
96516
96573
|
ops,
|
|
96574
|
+
preCompletionOps,
|
|
96517
96575
|
closureVars: hydratedInput.closureVars,
|
|
96518
96576
|
encryptionKey
|
|
96519
96577
|
}, () => stepFn.apply(thisVal, args));
|
|
@@ -96557,6 +96615,10 @@ async function executeStep(params) {
|
|
|
96557
96615
|
if (reconcile)
|
|
96558
96616
|
return reconcile;
|
|
96559
96617
|
}
|
|
96618
|
+
if (preCompletionOps.length > 0) {
|
|
96619
|
+
await Promise.all(preCompletionOps).catch(() => {
|
|
96620
|
+
});
|
|
96621
|
+
}
|
|
96560
96622
|
let stepCompleted409 = false;
|
|
96561
96623
|
const completedResult = await world.events.create(workflowRunId, {
|
|
96562
96624
|
eventType: "step_completed",
|
|
@@ -96602,6 +96664,10 @@ async function executeStep(params) {
|
|
|
96602
96664
|
if (reconcile)
|
|
96603
96665
|
return reconcile;
|
|
96604
96666
|
}
|
|
96667
|
+
if (preCompletionOps.length > 0) {
|
|
96668
|
+
await Promise.all(preCompletionOps).catch(() => {
|
|
96669
|
+
});
|
|
96670
|
+
}
|
|
96605
96671
|
const effectiveErr = promoteAbortErrorToFatal(err);
|
|
96606
96672
|
const normalizedError = await normalizeUnknownError(effectiveErr);
|
|
96607
96673
|
const normalizedStack = normalizedError.stack || getErrorStack(effectiveErr) || "";
|
|
@@ -96804,8 +96870,16 @@ async function createHookEvent({ world, runId, hookEvent, queueItem, requestId }
|
|
|
96804
96870
|
}
|
|
96805
96871
|
}
|
|
96806
96872
|
__name(createHookEvent, "createHookEvent");
|
|
96807
|
-
async function handleSuspension({ suspension, world, run: run3, span, requestId }) {
|
|
96873
|
+
async function handleSuspension({ suspension, world, run: run3, span, requestId, runReadyBarrier }) {
|
|
96808
96874
|
const runId = run3.runId;
|
|
96875
|
+
const ensureRunReady = /* @__PURE__ */ __name(async () => {
|
|
96876
|
+
if (runReadyBarrier) {
|
|
96877
|
+
try {
|
|
96878
|
+
await runReadyBarrier;
|
|
96879
|
+
} catch {
|
|
96880
|
+
}
|
|
96881
|
+
}
|
|
96882
|
+
}, "ensureRunReady");
|
|
96809
96883
|
const stepItems = suspension.steps.filter((item) => item.type === "step");
|
|
96810
96884
|
const allHookItems = suspension.steps.filter((item) => item.type === "hook");
|
|
96811
96885
|
const waitItems = suspension.steps.filter((item) => item.type === "wait");
|
|
@@ -96835,6 +96909,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
|
|
|
96835
96909
|
let hasHookConflict = false;
|
|
96836
96910
|
let hasAwaitedHookCreation = false;
|
|
96837
96911
|
if (hookEvents.length > 0) {
|
|
96912
|
+
await ensureRunReady();
|
|
96838
96913
|
const results = await Promise.all(hookEvents.map(({ hookEvent, queueItem }) => createHookEvent({
|
|
96839
96914
|
world,
|
|
96840
96915
|
runId,
|
|
@@ -96846,6 +96921,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
|
|
|
96846
96921
|
hasAwaitedHookCreation = results.some((result) => result.hasAwaitedHookCreation);
|
|
96847
96922
|
}
|
|
96848
96923
|
if (hooksNeedingDisposal.length > 0) {
|
|
96924
|
+
await ensureRunReady();
|
|
96849
96925
|
await Promise.all(hooksNeedingDisposal.map(async (queueItem) => {
|
|
96850
96926
|
const hookDisposedEvent = {
|
|
96851
96927
|
eventType: "hook_disposed",
|
|
@@ -96884,6 +96960,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
|
|
|
96884
96960
|
}
|
|
96885
96961
|
const hooksNeedingAbort = allHookItems.filter((item) => item.abortRequested && !item.disposed);
|
|
96886
96962
|
if (hooksNeedingAbort.length > 0) {
|
|
96963
|
+
await ensureRunReady();
|
|
96887
96964
|
await Promise.all(hooksNeedingAbort.map(async (queueItem) => {
|
|
96888
96965
|
try {
|
|
96889
96966
|
const abortPayload = await dehydrateStepArguments2({ aborted: true, reason: queueItem.abortReason }, runId, encryptionKey, suspension.globalThis, false, compression);
|
|
@@ -96951,6 +97028,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
|
|
|
96951
97028
|
}
|
|
96952
97029
|
};
|
|
96953
97030
|
try {
|
|
97031
|
+
await ensureRunReady();
|
|
96954
97032
|
await world.events.create(runId, stepEvent, { requestId });
|
|
96955
97033
|
createdStepCorrelationIds.add(queueItem.correlationId);
|
|
96956
97034
|
} catch (err) {
|
|
@@ -96979,6 +97057,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
|
|
|
96979
97057
|
}
|
|
96980
97058
|
};
|
|
96981
97059
|
try {
|
|
97060
|
+
await ensureRunReady();
|
|
96982
97061
|
await world.events.create(runId, waitEvent, { requestId });
|
|
96983
97062
|
} catch (err) {
|
|
96984
97063
|
if (EntityConflictError2.is(err)) {
|
|
@@ -96997,6 +97076,7 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
|
|
|
96997
97076
|
for (const queueItem of attributeItems) {
|
|
96998
97077
|
ops.push((async () => {
|
|
96999
97078
|
try {
|
|
97079
|
+
await ensureRunReady();
|
|
97000
97080
|
await world.events.create(runId, {
|
|
97001
97081
|
eventType: "attr_set",
|
|
97002
97082
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
@@ -97059,7 +97139,8 @@ async function handleSuspension({ suspension, world, run: run3, span, requestId
|
|
|
97059
97139
|
waitTimeout: hasHookConflict ? void 0 : soonestWait,
|
|
97060
97140
|
hasHookConflict,
|
|
97061
97141
|
hasAwaitedHookCreation,
|
|
97062
|
-
hasAttributeEvents: attributeItems.length > 0
|
|
97142
|
+
hasAttributeEvents: attributeItems.length > 0,
|
|
97143
|
+
hasHookEvents: hookEvents.length > 0
|
|
97063
97144
|
};
|
|
97064
97145
|
}
|
|
97065
97146
|
__name(handleSuspension, "handleSuspension");
|
|
@@ -97697,6 +97778,42 @@ function remapErrorStack(stack, filename, workflowCode2) {
|
|
|
97697
97778
|
}
|
|
97698
97779
|
__name(remapErrorStack, "remapErrorStack");
|
|
97699
97780
|
|
|
97781
|
+
// ../core/dist/step-hydration-cache.js
|
|
97782
|
+
var MAX_MEMOIZED_PRIMITIVE_LENGTH = 4096;
|
|
97783
|
+
function isMemoizablePrimitive(value) {
|
|
97784
|
+
if (value === null)
|
|
97785
|
+
return true;
|
|
97786
|
+
const t = typeof value;
|
|
97787
|
+
if (t === "object" || t === "function")
|
|
97788
|
+
return false;
|
|
97789
|
+
if (t === "string") {
|
|
97790
|
+
return value.length <= MAX_MEMOIZED_PRIMITIVE_LENGTH;
|
|
97791
|
+
}
|
|
97792
|
+
if (t === "bigint") {
|
|
97793
|
+
return value.toString().length <= MAX_MEMOIZED_PRIMITIVE_LENGTH;
|
|
97794
|
+
}
|
|
97795
|
+
return true;
|
|
97796
|
+
}
|
|
97797
|
+
__name(isMemoizablePrimitive, "isMemoizablePrimitive");
|
|
97798
|
+
function createStepHydrationCache() {
|
|
97799
|
+
return /* @__PURE__ */ new Map();
|
|
97800
|
+
}
|
|
97801
|
+
__name(createStepHydrationCache, "createStepHydrationCache");
|
|
97802
|
+
async function getOrHydrateStepReturnValue(cache, eventId, hydrate) {
|
|
97803
|
+
if (!cache || eventId === void 0) {
|
|
97804
|
+
return hydrate();
|
|
97805
|
+
}
|
|
97806
|
+
if (cache.has(eventId)) {
|
|
97807
|
+
return cache.get(eventId);
|
|
97808
|
+
}
|
|
97809
|
+
const value = await hydrate();
|
|
97810
|
+
if (isMemoizablePrimitive(value)) {
|
|
97811
|
+
cache.set(eventId, value);
|
|
97812
|
+
}
|
|
97813
|
+
return value;
|
|
97814
|
+
}
|
|
97815
|
+
__name(getOrHydrateStepReturnValue, "getOrHydrateStepReturnValue");
|
|
97816
|
+
|
|
97700
97817
|
// ../core/dist/runtime.js
|
|
97701
97818
|
init_semantic_conventions2();
|
|
97702
97819
|
init_telemetry2();
|
|
@@ -97844,10 +97961,12 @@ function createUseStep(ctx) {
|
|
|
97844
97961
|
}
|
|
97845
97962
|
if (event.eventType === "step_completed") {
|
|
97846
97963
|
ctx.invocationsQueue.delete(event.correlationId);
|
|
97964
|
+
const completedEventId = event.eventId;
|
|
97965
|
+
const serializedResult = event.eventData.result;
|
|
97847
97966
|
ctx.pendingDeliveries++;
|
|
97848
97967
|
ctx.promiseQueue = ctx.promiseQueue.then(async () => {
|
|
97849
97968
|
try {
|
|
97850
|
-
const hydratedResult = await
|
|
97969
|
+
const hydratedResult = await getOrHydrateStepReturnValue(ctx.stepHydrationCache, completedEventId, () => hydrateStepReturnValue(serializedResult, ctx.runId, ctx.encryptionKey, ctx.globalThis));
|
|
97851
97970
|
resolve3(hydratedResult);
|
|
97852
97971
|
} catch (error95) {
|
|
97853
97972
|
reject(error95);
|
|
@@ -98862,7 +98981,7 @@ async function drainPendingQueueItems(runId, pendingQueue, vmGlobalThis, workflo
|
|
|
98862
98981
|
}
|
|
98863
98982
|
}
|
|
98864
98983
|
__name(drainPendingQueueItems, "drainPendingQueueItems");
|
|
98865
|
-
async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
|
|
98984
|
+
async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey, stepHydrationCache) {
|
|
98866
98985
|
return trace3(`workflow.run ${workflowRun.workflowName}`, async (span) => {
|
|
98867
98986
|
span?.setAttributes({
|
|
98868
98987
|
...WorkflowName2(workflowRun.workflowName),
|
|
@@ -98900,7 +99019,16 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
|
|
|
98900
99019
|
globalThis: vmGlobalThis,
|
|
98901
99020
|
onWorkflowError: workflowDiscontinuation.reject,
|
|
98902
99021
|
eventsConsumer,
|
|
98903
|
-
|
|
99022
|
+
// Correlation IDs (step_/wait_/hook_) are derived from `generateUlid`, so
|
|
99023
|
+
// the time prefix fed to `ulid()` MUST be replay-stable across every
|
|
99024
|
+
// delivery — otherwise a redelivery regenerates different correlation IDs
|
|
99025
|
+
// and replay throws ReplayDivergenceError. `startedAt` is NOT safe here:
|
|
99026
|
+
// under turbo the first delivery synthesizes `startedAt` from the local
|
|
99027
|
+
// clock, but later (non-turbo) deliveries load the server-canonical
|
|
99028
|
+
// `startedAt`, which differs by >=1ms. Use the same replay-stable value
|
|
99029
|
+
// that already seeds the RNG and the VM clock (`fixedTimestamp`, recovered
|
|
99030
|
+
// from the run ID's ULID and known the instant the message arrives).
|
|
99031
|
+
generateUlid: /* @__PURE__ */ __name(() => ulid8(fixedTimestamp), "generateUlid"),
|
|
98904
99032
|
generateNanoid,
|
|
98905
99033
|
invocationsQueue: /* @__PURE__ */ new Map(),
|
|
98906
99034
|
// Use getter/setter so the EventsConsumer's getPromiseQueue() always
|
|
@@ -98912,7 +99040,8 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey) {
|
|
|
98912
99040
|
promiseQueueHolder.current = value;
|
|
98913
99041
|
},
|
|
98914
99042
|
pendingDeliveries: 0,
|
|
98915
|
-
pendingDeliveryBarriers: /* @__PURE__ */ new Map()
|
|
99043
|
+
pendingDeliveryBarriers: /* @__PURE__ */ new Map(),
|
|
99044
|
+
stepHydrationCache
|
|
98916
99045
|
};
|
|
98917
99046
|
workflowContext.eventsConsumer.subscribe((event) => {
|
|
98918
99047
|
if (!event) {
|
|
@@ -99877,11 +100006,32 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
99877
100006
|
let loopIteration = 0;
|
|
99878
100007
|
let cachedEvents = null;
|
|
99879
100008
|
let eventsCursor = null;
|
|
100009
|
+
const stepHydrationCache = createStepHydrationCache();
|
|
99880
100010
|
let pendingInlineDelta = null;
|
|
99881
100011
|
let workflowRun;
|
|
99882
100012
|
let workflowStartedAt = -1;
|
|
99883
100013
|
let preloadedEvents;
|
|
99884
100014
|
let preloadedEventsCursor;
|
|
100015
|
+
const turbo = isTurboEnabled() && runInput !== void 0 && metadata.attempt === 1 && incomingStepId === void 0 && !replayDivergence;
|
|
100016
|
+
let runReadyBarrier;
|
|
100017
|
+
const awaitRunReady = /* @__PURE__ */ __name(async () => {
|
|
100018
|
+
if (runReadyBarrier) {
|
|
100019
|
+
try {
|
|
100020
|
+
await runReadyBarrier;
|
|
100021
|
+
} catch {
|
|
100022
|
+
}
|
|
100023
|
+
}
|
|
100024
|
+
}, "awaitRunReady");
|
|
100025
|
+
const reinvoke = /* @__PURE__ */ __name(async (delaySeconds) => {
|
|
100026
|
+
if (!turbo)
|
|
100027
|
+
return { timeoutSeconds: delaySeconds };
|
|
100028
|
+
await queueMessage(world, getWorkflowQueueName2(workflowName, namespace), {
|
|
100029
|
+
runId,
|
|
100030
|
+
traceCarrier: await nextTraceCarrier(),
|
|
100031
|
+
requestedAt: /* @__PURE__ */ new Date()
|
|
100032
|
+
}, delaySeconds > 0 ? { delaySeconds } : void 0);
|
|
100033
|
+
return void 0;
|
|
100034
|
+
}, "reinvoke");
|
|
99885
100035
|
if (incomingStepId && incomingStepName) {
|
|
99886
100036
|
try {
|
|
99887
100037
|
const bgRun = await world.runs.get(runId);
|
|
@@ -99968,72 +100118,123 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
99968
100118
|
}
|
|
99969
100119
|
}
|
|
99970
100120
|
if (!workflowRun) {
|
|
99971
|
-
|
|
99972
|
-
|
|
99973
|
-
|
|
99974
|
-
|
|
99975
|
-
|
|
99976
|
-
|
|
99977
|
-
|
|
99978
|
-
|
|
99979
|
-
|
|
99980
|
-
|
|
99981
|
-
|
|
99982
|
-
|
|
99983
|
-
|
|
99984
|
-
|
|
99985
|
-
|
|
99986
|
-
|
|
99987
|
-
|
|
99988
|
-
|
|
99989
|
-
|
|
100121
|
+
const runStartedEvent = {
|
|
100122
|
+
eventType: "run_started",
|
|
100123
|
+
// Use the spec version from the original start() call
|
|
100124
|
+
// when available, so the resilient start path creates
|
|
100125
|
+
// the run with the correct version (not always current).
|
|
100126
|
+
specVersion: runInput?.specVersion ?? SPEC_VERSION_CURRENT2,
|
|
100127
|
+
// Pass run input from queue so the server can
|
|
100128
|
+
// create the run if run_created was missed.
|
|
100129
|
+
// Uint8Array values survive the queue natively
|
|
100130
|
+
// (CBOR on world-vercel, JSON reviver on world-local).
|
|
100131
|
+
...runInput ? {
|
|
100132
|
+
eventData: {
|
|
100133
|
+
input: runInput.input,
|
|
100134
|
+
deploymentId: runInput.deploymentId,
|
|
100135
|
+
workflowName: runInput.workflowName,
|
|
100136
|
+
executionContext: runInput.executionContext,
|
|
100137
|
+
attributes: runInput.attributes,
|
|
100138
|
+
allowReservedAttributes: runInput.allowReservedAttributes
|
|
100139
|
+
}
|
|
100140
|
+
} : {}
|
|
100141
|
+
};
|
|
100142
|
+
if (turbo && runInput) {
|
|
100143
|
+
const startedPromise = world.events.create(
|
|
100144
|
+
runId,
|
|
100145
|
+
runStartedEvent,
|
|
100146
|
+
// We background this purely as a write barrier and
|
|
100147
|
+
// never read its preloaded events (preloadedEvents is
|
|
100148
|
+
// forced to [] below), so tell the World to skip the
|
|
100149
|
+
// run_started event-log preload. That trims the
|
|
100150
|
+
// run_started request the chained first step_started
|
|
100151
|
+
// waits on — shortening time-to-second-step — and the
|
|
100152
|
+
// wasted list+resolve it would otherwise compute.
|
|
100153
|
+
{ requestId, skipPreload: true }
|
|
100154
|
+
);
|
|
100155
|
+
runReadyBarrier = startedPromise;
|
|
100156
|
+
startedPromise.catch(() => {
|
|
100157
|
+
});
|
|
100158
|
+
preloadedEvents = [];
|
|
100159
|
+
const now = /* @__PURE__ */ new Date();
|
|
100160
|
+
workflowRun = {
|
|
100161
|
+
runId,
|
|
100162
|
+
status: "running",
|
|
100163
|
+
deploymentId: runInput.deploymentId,
|
|
100164
|
+
workflowName: runInput.workflowName,
|
|
100165
|
+
specVersion: runInput.specVersion,
|
|
100166
|
+
executionContext: runInput.executionContext,
|
|
100167
|
+
input: runInput.input,
|
|
100168
|
+
// Seed attributes from start() ride along in `runInput`
|
|
100169
|
+
// (they live in `run_created`'s eventData, not separate
|
|
100170
|
+
// `attr_set` events), so the synthesized snapshot carries
|
|
100171
|
+
// them even though we skip the initial events.list. This
|
|
100172
|
+
// is correct ONLY while attributes are write-only:
|
|
100173
|
+
// there is no in-workflow read API today (see workflow.ts
|
|
100174
|
+
// "structural until a read API is introduced"), so the
|
|
100175
|
+
// empty preloaded log can't diverge on a read. If a read
|
|
100176
|
+
// API is ever added it MUST read from this snapshot, not
|
|
100177
|
+
// by replaying run_created/attr_set events — otherwise
|
|
100178
|
+
// turbo's empty initial log would surface seed attributes
|
|
100179
|
+
// as `{}` on the first delivery only.
|
|
100180
|
+
attributes: runInput.attributes ?? {},
|
|
100181
|
+
startedAt: now,
|
|
100182
|
+
createdAt: now,
|
|
100183
|
+
updatedAt: now
|
|
100184
|
+
};
|
|
100185
|
+
workflowStartedAt = +now;
|
|
100186
|
+
span?.setAttributes({
|
|
100187
|
+
...WorkflowRunStatus2("running"),
|
|
100188
|
+
...WorkflowStartedAt2(workflowStartedAt)
|
|
100189
|
+
});
|
|
100190
|
+
} else {
|
|
100191
|
+
try {
|
|
100192
|
+
const result = await world.events.create(runId, runStartedEvent, { requestId });
|
|
100193
|
+
if (!result.run) {
|
|
100194
|
+
throw new WorkflowRuntimeError2(`Event creation for 'run_started' did not return the run entity for run "${runId}"`);
|
|
100195
|
+
}
|
|
100196
|
+
workflowRun = result.run;
|
|
100197
|
+
if (result.events && result.events.length > 0 && result.hasMore !== true) {
|
|
100198
|
+
preloadedEvents = result.events;
|
|
100199
|
+
preloadedEventsCursor = result.cursor;
|
|
100200
|
+
}
|
|
100201
|
+
if (!workflowRun.startedAt) {
|
|
100202
|
+
throw new WorkflowRuntimeError2(`Workflow run "${runId}" has no "startedAt" timestamp`);
|
|
100203
|
+
}
|
|
100204
|
+
} catch (err) {
|
|
100205
|
+
if (EntityConflictError2.is(err) || RunExpiredError.is(err)) {
|
|
100206
|
+
runtimeLogger2.info("Run already finished during setup, skipping", { workflowRunId: runId, message: err.message });
|
|
100207
|
+
return;
|
|
100208
|
+
} else {
|
|
100209
|
+
const errorCode = getWorkflowSetupErrorCode(err);
|
|
100210
|
+
if (!errorCode) {
|
|
100211
|
+
throw err;
|
|
99990
100212
|
}
|
|
99991
|
-
|
|
99992
|
-
|
|
99993
|
-
|
|
99994
|
-
|
|
99995
|
-
|
|
99996
|
-
|
|
99997
|
-
|
|
99998
|
-
|
|
99999
|
-
|
|
100000
|
-
|
|
100001
|
-
if (!workflowRun.startedAt) {
|
|
100002
|
-
throw new WorkflowRuntimeError2(`Workflow run "${runId}" has no "startedAt" timestamp`);
|
|
100003
|
-
}
|
|
100004
|
-
} catch (err) {
|
|
100005
|
-
if (EntityConflictError2.is(err) || RunExpiredError.is(err)) {
|
|
100006
|
-
runtimeLogger2.info("Run already finished during setup, skipping", { workflowRunId: runId, message: err.message });
|
|
100007
|
-
return;
|
|
100008
|
-
} else {
|
|
100009
|
-
const errorCode = getWorkflowSetupErrorCode(err);
|
|
100010
|
-
if (!errorCode) {
|
|
100011
|
-
throw err;
|
|
100213
|
+
await recordFatalRunError({
|
|
100214
|
+
world,
|
|
100215
|
+
workflowRun,
|
|
100216
|
+
runId,
|
|
100217
|
+
requestId,
|
|
100218
|
+
err,
|
|
100219
|
+
errorCode,
|
|
100220
|
+
logMessage: "Fatal runtime error during workflow setup"
|
|
100221
|
+
});
|
|
100222
|
+
return;
|
|
100012
100223
|
}
|
|
100013
|
-
|
|
100014
|
-
|
|
100015
|
-
|
|
100016
|
-
|
|
100017
|
-
|
|
100018
|
-
|
|
100019
|
-
|
|
100020
|
-
|
|
100224
|
+
}
|
|
100225
|
+
workflowStartedAt = +workflowRun.startedAt;
|
|
100226
|
+
span?.setAttributes({
|
|
100227
|
+
...WorkflowRunStatus2(workflowRun.status),
|
|
100228
|
+
...WorkflowStartedAt2(workflowStartedAt)
|
|
100229
|
+
});
|
|
100230
|
+
if (workflowRun.status !== "running") {
|
|
100231
|
+
runtimeLogger2.info("Workflow already completed or failed, skipping", {
|
|
100232
|
+
workflowRunId: runId,
|
|
100233
|
+
status: workflowRun.status
|
|
100021
100234
|
});
|
|
100022
100235
|
return;
|
|
100023
100236
|
}
|
|
100024
100237
|
}
|
|
100025
|
-
workflowStartedAt = +workflowRun.startedAt;
|
|
100026
|
-
span?.setAttributes({
|
|
100027
|
-
...WorkflowRunStatus2(workflowRun.status),
|
|
100028
|
-
...WorkflowStartedAt2(workflowStartedAt)
|
|
100029
|
-
});
|
|
100030
|
-
if (workflowRun.status !== "running") {
|
|
100031
|
-
runtimeLogger2.info("Workflow already completed or failed, skipping", {
|
|
100032
|
-
workflowRunId: runId,
|
|
100033
|
-
status: workflowRun.status
|
|
100034
|
-
});
|
|
100035
|
-
return;
|
|
100036
|
-
}
|
|
100037
100238
|
}
|
|
100038
100239
|
const getEncryptionKey = memoizeEncryptionKey(world, workflowRun);
|
|
100039
100240
|
const encryptionKey = await getEncryptionKey();
|
|
@@ -100180,13 +100381,14 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100180
100381
|
eventCount: events.length
|
|
100181
100382
|
});
|
|
100182
100383
|
replayStart = Date.now();
|
|
100183
|
-
const result = await runWorkflow(workflowCode2, workflowRun, events, encryptionKey);
|
|
100384
|
+
const result = await runWorkflow(workflowCode2, workflowRun, events, encryptionKey, stepHydrationCache);
|
|
100184
100385
|
runtimeLogger2.debug("Workflow replay completed", {
|
|
100185
100386
|
workflowRunId: runId,
|
|
100186
100387
|
loopIteration,
|
|
100187
100388
|
replayMs: Date.now() - replayStart
|
|
100188
100389
|
});
|
|
100189
100390
|
try {
|
|
100391
|
+
await awaitRunReady();
|
|
100190
100392
|
await world.events.create(runId, {
|
|
100191
100393
|
eventType: "run_completed",
|
|
100192
100394
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
@@ -100225,7 +100427,8 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100225
100427
|
world,
|
|
100226
100428
|
run: workflowRun,
|
|
100227
100429
|
span,
|
|
100228
|
-
requestId
|
|
100430
|
+
requestId,
|
|
100431
|
+
runReadyBarrier
|
|
100229
100432
|
});
|
|
100230
100433
|
} catch (suspensionError) {
|
|
100231
100434
|
if (!FatalError2.is(suspensionError)) {
|
|
@@ -100239,6 +100442,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100239
100442
|
errorMessage: suspensionError.message
|
|
100240
100443
|
});
|
|
100241
100444
|
try {
|
|
100445
|
+
await awaitRunReady();
|
|
100242
100446
|
await world.events.create(runId, {
|
|
100243
100447
|
eventType: "run_failed",
|
|
100244
100448
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
@@ -100276,10 +100480,10 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100276
100480
|
hasAttributeEvents: suspensionResult.hasAttributeEvents
|
|
100277
100481
|
});
|
|
100278
100482
|
if (suspensionResult.hasHookConflict) {
|
|
100279
|
-
return
|
|
100483
|
+
return await reinvoke(0);
|
|
100280
100484
|
}
|
|
100281
100485
|
if (suspensionResult.hasAttributeEvents) {
|
|
100282
|
-
return
|
|
100486
|
+
return await reinvoke(0);
|
|
100283
100487
|
}
|
|
100284
100488
|
const pendingSteps = suspensionResult.pendingSteps;
|
|
100285
100489
|
const lazyInlineSteps = suspensionResult.lazyInlineSteps;
|
|
@@ -100310,11 +100514,12 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100310
100514
|
await Promise.all(dispatches);
|
|
100311
100515
|
if (lazyInlineSteps.length === 0) {
|
|
100312
100516
|
if (suspensionResult.hasAwaitedHookCreation) {
|
|
100313
|
-
return
|
|
100517
|
+
return await reinvoke(0);
|
|
100314
100518
|
}
|
|
100315
100519
|
return;
|
|
100316
100520
|
}
|
|
100317
100521
|
const requestInlineDelta = typeof preInlineWriteCursor === "string" && err.stepCount === 1 && err.hookCount === 0 && err.waitCount === 0 && pendingSteps.length === 1 && lazyInlineSteps.length === 1 && !suspensionResult.waitTimeout && !hasOpenHookOrWait(cachedEvents ?? []);
|
|
100522
|
+
const forceOptimisticStart = turbo && !suspensionResult.waitTimeout && !suspensionResult.hasHookEvents && !suspensionResult.hasAttributeEvents && !suspensionResult.hasAwaitedHookCreation && !hasOpenHookOrWait(cachedEvents ?? []);
|
|
100318
100523
|
replayBudget.pause();
|
|
100319
100524
|
let stepResults;
|
|
100320
100525
|
try {
|
|
@@ -100331,6 +100536,12 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100331
100536
|
// input on step_started so the world creates the
|
|
100332
100537
|
// step on the fly.
|
|
100333
100538
|
lazyStepInput: s.dehydratedInput,
|
|
100539
|
+
// Turbo: force optimistic start and hold the lazy
|
|
100540
|
+
// step_started until the backgrounded run_started
|
|
100541
|
+
// lands (the body still runs immediately). Both
|
|
100542
|
+
// are undefined/false outside turbo.
|
|
100543
|
+
forceOptimisticStart,
|
|
100544
|
+
runReadyBarrier,
|
|
100334
100545
|
...requestInlineDelta && preInlineWriteCursor ? {
|
|
100335
100546
|
inlineDeltaSinceCursor: preInlineWriteCursor
|
|
100336
100547
|
} : {}
|
|
@@ -100356,7 +100567,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100356
100567
|
}
|
|
100357
100568
|
}
|
|
100358
100569
|
if (throttleTimeout !== void 0) {
|
|
100359
|
-
return
|
|
100570
|
+
return await reinvoke(throttleTimeout);
|
|
100360
100571
|
}
|
|
100361
100572
|
if (toRetry.length > 0) {
|
|
100362
100573
|
const retryTraceCarrier = await nextTraceCarrier();
|
|
@@ -100465,6 +100676,7 @@ function workflowEntrypoint(workflowCode2, options) {
|
|
|
100465
100676
|
terminalError.stack = errorStack;
|
|
100466
100677
|
}
|
|
100467
100678
|
try {
|
|
100679
|
+
await awaitRunReady();
|
|
100468
100680
|
await world.events.create(runId, {
|
|
100469
100681
|
eventType: "run_failed",
|
|
100470
100682
|
specVersion: SPEC_VERSION_CURRENT2,
|
|
@@ -116432,6 +116644,7 @@ var EventSchema = AllEventsSchema.and(external_exports.object({
|
|
|
116432
116644
|
runId: external_exports.string(),
|
|
116433
116645
|
eventId: external_exports.string(),
|
|
116434
116646
|
createdAt: external_exports.coerce.date(),
|
|
116647
|
+
occurredAt: external_exports.coerce.date().optional(),
|
|
116435
116648
|
specVersion: external_exports.number().optional()
|
|
116436
116649
|
}));
|
|
116437
116650
|
|
|
@@ -116794,10 +117007,10 @@ var Run = class _Run {
|
|
|
116794
117007
|
return this.getReadable();
|
|
116795
117008
|
}
|
|
116796
117009
|
};
|
|
116797
|
-
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
116798
|
-
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
116799
|
-
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
116800
|
-
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
117010
|
+
Run.prototype["wakeUp"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#wakeUp");
|
|
117011
|
+
Run.prototype["cancel"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#cancel");
|
|
117012
|
+
Run.prototype["getReadable"] = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#getReadable");
|
|
117013
|
+
var __step_Run$exists = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#exists");
|
|
116801
117014
|
Object.defineProperty(Run.prototype, "exists", {
|
|
116802
117015
|
get() {
|
|
116803
117016
|
return __step_Run$exists.call(this);
|
|
@@ -116805,7 +117018,7 @@ Object.defineProperty(Run.prototype, "exists", {
|
|
|
116805
117018
|
configurable: true,
|
|
116806
117019
|
enumerable: false
|
|
116807
117020
|
});
|
|
116808
|
-
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
117021
|
+
var __step_Run$status = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#status");
|
|
116809
117022
|
Object.defineProperty(Run.prototype, "status", {
|
|
116810
117023
|
get() {
|
|
116811
117024
|
return __step_Run$status.call(this);
|
|
@@ -116813,7 +117026,7 @@ Object.defineProperty(Run.prototype, "status", {
|
|
|
116813
117026
|
configurable: true,
|
|
116814
117027
|
enumerable: false
|
|
116815
117028
|
});
|
|
116816
|
-
var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
117029
|
+
var __step_Run$returnValue = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#returnValue");
|
|
116817
117030
|
Object.defineProperty(Run.prototype, "returnValue", {
|
|
116818
117031
|
get() {
|
|
116819
117032
|
return __step_Run$returnValue.call(this);
|
|
@@ -116821,7 +117034,7 @@ Object.defineProperty(Run.prototype, "returnValue", {
|
|
|
116821
117034
|
configurable: true,
|
|
116822
117035
|
enumerable: false
|
|
116823
117036
|
});
|
|
116824
|
-
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
117037
|
+
var __step_Run$workflowName = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#workflowName");
|
|
116825
117038
|
Object.defineProperty(Run.prototype, "workflowName", {
|
|
116826
117039
|
get() {
|
|
116827
117040
|
return __step_Run$workflowName.call(this);
|
|
@@ -116829,7 +117042,7 @@ Object.defineProperty(Run.prototype, "workflowName", {
|
|
|
116829
117042
|
configurable: true,
|
|
116830
117043
|
enumerable: false
|
|
116831
117044
|
});
|
|
116832
|
-
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
117045
|
+
var __step_Run$createdAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#createdAt");
|
|
116833
117046
|
Object.defineProperty(Run.prototype, "createdAt", {
|
|
116834
117047
|
get() {
|
|
116835
117048
|
return __step_Run$createdAt.call(this);
|
|
@@ -116837,7 +117050,7 @@ Object.defineProperty(Run.prototype, "createdAt", {
|
|
|
116837
117050
|
configurable: true,
|
|
116838
117051
|
enumerable: false
|
|
116839
117052
|
});
|
|
116840
|
-
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
117053
|
+
var __step_Run$startedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#startedAt");
|
|
116841
117054
|
Object.defineProperty(Run.prototype, "startedAt", {
|
|
116842
117055
|
get() {
|
|
116843
117056
|
return __step_Run$startedAt.call(this);
|
|
@@ -116845,7 +117058,7 @@ Object.defineProperty(Run.prototype, "startedAt", {
|
|
|
116845
117058
|
configurable: true,
|
|
116846
117059
|
enumerable: false
|
|
116847
117060
|
});
|
|
116848
|
-
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.
|
|
117061
|
+
var __step_Run$completedAt = globalThis[/* @__PURE__ */ Symbol.for("WORKFLOW_USE_STEP")]("step//@workflow/core/runtime/run@5.0.0-beta.22//Run#completedAt");
|
|
116849
117062
|
Object.defineProperty(Run.prototype, "completedAt", {
|
|
116850
117063
|
get() {
|
|
116851
117064
|
return __step_Run$completedAt.call(this);
|
|
@@ -116862,7 +117075,7 @@ Object.defineProperty(Run.prototype, "completedAt", {
|
|
|
116862
117075
|
enumerable: false,
|
|
116863
117076
|
configurable: false
|
|
116864
117077
|
});
|
|
116865
|
-
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.
|
|
117078
|
+
})(Run, "class//@workflow/core/runtime/run@5.0.0-beta.22//Run");
|
|
116866
117079
|
|
|
116867
117080
|
// ../core/dist/workflow/create-hook.js
|
|
116868
117081
|
aliasSerializationClass(RUN_CLASS_ID, Run);
|