@workflow/world-testing 4.1.0-beta.59 → 4.1.0-beta.60
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/.well-known/workflow/v1/flow.js +222 -57
- package/dist/.well-known/workflow/v1/flow.js.map +1 -1
- package/dist/.well-known/workflow/v1/manifest.json +93 -93
- package/dist/.well-known/workflow/v1/step.js +235 -53
- package/dist/.well-known/workflow/v1/step.js.map +1 -1
- package/package.json +5 -5
|
@@ -2735,7 +2735,7 @@ var require_token_util = __commonJS({
|
|
|
2735
2735
|
getTokenPayload: /* @__PURE__ */ __name(() => getTokenPayload, "getTokenPayload"),
|
|
2736
2736
|
getVercelCliToken: /* @__PURE__ */ __name(() => getVercelCliToken, "getVercelCliToken"),
|
|
2737
2737
|
getVercelDataDir: /* @__PURE__ */ __name(() => getVercelDataDir, "getVercelDataDir"),
|
|
2738
|
-
getVercelOidcToken: /* @__PURE__ */ __name(() =>
|
|
2738
|
+
getVercelOidcToken: /* @__PURE__ */ __name(() => getVercelOidcToken6, "getVercelOidcToken"),
|
|
2739
2739
|
isExpired: /* @__PURE__ */ __name(() => isExpired, "isExpired"),
|
|
2740
2740
|
loadToken: /* @__PURE__ */ __name(() => loadToken, "loadToken"),
|
|
2741
2741
|
saveToken: /* @__PURE__ */ __name(() => saveToken, "saveToken")
|
|
@@ -2770,7 +2770,7 @@ var require_token_util = __commonJS({
|
|
|
2770
2770
|
return JSON.parse(token).token;
|
|
2771
2771
|
}
|
|
2772
2772
|
__name(getVercelCliToken, "getVercelCliToken");
|
|
2773
|
-
async function
|
|
2773
|
+
async function getVercelOidcToken6(authToken, projectId, teamId) {
|
|
2774
2774
|
try {
|
|
2775
2775
|
const url2 = `https://api.vercel.com/v1/projects/${projectId}/token?source=vercel-oidc-refresh${teamId ? `&teamId=${teamId}` : ""}`;
|
|
2776
2776
|
const res = await fetch(url2, {
|
|
@@ -2790,7 +2790,7 @@ var require_token_util = __commonJS({
|
|
|
2790
2790
|
throw new import_token_error.VercelOidcTokenError(`Failed to refresh OIDC token`, e);
|
|
2791
2791
|
}
|
|
2792
2792
|
}
|
|
2793
|
-
__name(
|
|
2793
|
+
__name(getVercelOidcToken6, "getVercelOidcToken");
|
|
2794
2794
|
function assertVercelOidcTokenResponse(res) {
|
|
2795
2795
|
if (!res || typeof res !== "object") {
|
|
2796
2796
|
throw new TypeError("Expected an object");
|
|
@@ -2948,13 +2948,13 @@ var require_get_vercel_oidc_token = __commonJS({
|
|
|
2948
2948
|
var __toCommonJS2 = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod), "__toCommonJS");
|
|
2949
2949
|
var get_vercel_oidc_token_exports = {};
|
|
2950
2950
|
__export2(get_vercel_oidc_token_exports, {
|
|
2951
|
-
getVercelOidcToken: /* @__PURE__ */ __name(() =>
|
|
2951
|
+
getVercelOidcToken: /* @__PURE__ */ __name(() => getVercelOidcToken6, "getVercelOidcToken"),
|
|
2952
2952
|
getVercelOidcTokenSync: /* @__PURE__ */ __name(() => getVercelOidcTokenSync2, "getVercelOidcTokenSync")
|
|
2953
2953
|
});
|
|
2954
2954
|
module2.exports = __toCommonJS2(get_vercel_oidc_token_exports);
|
|
2955
2955
|
var import_get_context = require_get_context();
|
|
2956
2956
|
var import_token_error = require_token_error();
|
|
2957
|
-
async function
|
|
2957
|
+
async function getVercelOidcToken6() {
|
|
2958
2958
|
let token = "";
|
|
2959
2959
|
let err;
|
|
2960
2960
|
try {
|
|
@@ -2982,7 +2982,7 @@ ${error45.message}`;
|
|
|
2982
2982
|
}
|
|
2983
2983
|
return token;
|
|
2984
2984
|
}
|
|
2985
|
-
__name(
|
|
2985
|
+
__name(getVercelOidcToken6, "getVercelOidcToken");
|
|
2986
2986
|
function getVercelOidcTokenSync2() {
|
|
2987
2987
|
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
2988
2988
|
if (!token) {
|
|
@@ -37329,6 +37329,18 @@ var WaitSchema = external_exports.object({
|
|
|
37329
37329
|
updatedAt: external_exports.coerce.date(),
|
|
37330
37330
|
specVersion: external_exports.number().optional()
|
|
37331
37331
|
});
|
|
37332
|
+
// ../core/dist/encryption.js
|
|
37333
|
+
var KEY_LENGTH = 32;
|
|
37334
|
+
async function importKey(raw) {
|
|
37335
|
+
if (raw.byteLength !== KEY_LENGTH) {
|
|
37336
|
+
throw new Error(`Encryption key must be exactly ${KEY_LENGTH} bytes, got ${raw.byteLength}`);
|
|
37337
|
+
}
|
|
37338
|
+
return globalThis.crypto.subtle.importKey("raw", raw, "AES-GCM", false, [
|
|
37339
|
+
"encrypt",
|
|
37340
|
+
"decrypt"
|
|
37341
|
+
]);
|
|
37342
|
+
}
|
|
37343
|
+
__name(importKey, "importKey");
|
|
37332
37344
|
// ../core/dist/global.js
|
|
37333
37345
|
var WorkflowSuspension = class _WorkflowSuspension extends Error {
|
|
37334
37346
|
static {
|
|
@@ -40909,10 +40921,85 @@ function createLocalWorld(args) {
|
|
|
40909
40921
|
};
|
|
40910
40922
|
}
|
|
40911
40923
|
__name(createLocalWorld, "createLocalWorld");
|
|
40924
|
+
// ../world-vercel/dist/encryption.js
|
|
40925
|
+
var import_node_crypto2 = require("node:crypto");
|
|
40926
|
+
var import_oidc2 = __toESM(require_dist(), 1);
|
|
40927
|
+
var KEY_BYTES = 32;
|
|
40928
|
+
async function deriveRunKey(deploymentKey, projectId, runId) {
|
|
40929
|
+
if (deploymentKey.length !== KEY_BYTES) {
|
|
40930
|
+
throw new Error(`Invalid deployment key length: expected ${KEY_BYTES} bytes for AES-256, got ${deploymentKey.length} bytes`);
|
|
40931
|
+
}
|
|
40932
|
+
if (!projectId || typeof projectId !== "string") {
|
|
40933
|
+
throw new Error("projectId must be a non-empty string");
|
|
40934
|
+
}
|
|
40935
|
+
const baseKey = await import_node_crypto2.webcrypto.subtle.importKey("raw", deploymentKey, "HKDF", false, ["deriveBits"]);
|
|
40936
|
+
const info = new TextEncoder().encode(`${projectId}|${runId}`);
|
|
40937
|
+
const derivedBits = await import_node_crypto2.webcrypto.subtle.deriveBits({
|
|
40938
|
+
name: "HKDF",
|
|
40939
|
+
hash: "SHA-256",
|
|
40940
|
+
salt: new Uint8Array(32),
|
|
40941
|
+
info
|
|
40942
|
+
}, baseKey, KEY_BYTES * 8
|
|
40943
|
+
// bits
|
|
40944
|
+
);
|
|
40945
|
+
return new Uint8Array(derivedBits);
|
|
40946
|
+
}
|
|
40947
|
+
__name(deriveRunKey, "deriveRunKey");
|
|
40948
|
+
async function fetchRunKey(deploymentId, projectId, runId, options) {
|
|
40949
|
+
const oidcToken = await (0, import_oidc2.getVercelOidcToken)().catch(() => null);
|
|
40950
|
+
const token = options?.token ?? oidcToken ?? process.env.VERCEL_TOKEN;
|
|
40951
|
+
if (!token) {
|
|
40952
|
+
throw new Error("Cannot fetch run key: no OIDC token or VERCEL_TOKEN available");
|
|
40953
|
+
}
|
|
40954
|
+
const params = new URLSearchParams({ projectId, runId });
|
|
40955
|
+
const response = await fetch(`https://api.vercel.com/v1/workflow/run-key/${deploymentId}?${params}`, {
|
|
40956
|
+
headers: {
|
|
40957
|
+
Authorization: `Bearer ${token}`
|
|
40958
|
+
}
|
|
40959
|
+
});
|
|
40960
|
+
if (!response.ok) {
|
|
40961
|
+
throw new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${response.status}`);
|
|
40962
|
+
}
|
|
40963
|
+
const data = await response.json();
|
|
40964
|
+
const result = object({ key: string2() }).safeParse(data);
|
|
40965
|
+
if (!result.success) {
|
|
40966
|
+
throw new Error('Invalid response from Vercel API, missing "key" field');
|
|
40967
|
+
}
|
|
40968
|
+
return Buffer.from(result.data.key, "base64");
|
|
40969
|
+
}
|
|
40970
|
+
__name(fetchRunKey, "fetchRunKey");
|
|
40971
|
+
function createGetEncryptionKeyForRun(projectId, token) {
|
|
40972
|
+
if (!projectId)
|
|
40973
|
+
return void 0;
|
|
40974
|
+
const currentDeploymentId = process.env.VERCEL_DEPLOYMENT_ID;
|
|
40975
|
+
let localDeploymentKey;
|
|
40976
|
+
function getLocalDeploymentKey() {
|
|
40977
|
+
if (localDeploymentKey)
|
|
40978
|
+
return localDeploymentKey;
|
|
40979
|
+
const deploymentKeyBase64 = process.env.VERCEL_DEPLOYMENT_KEY;
|
|
40980
|
+
if (!deploymentKeyBase64)
|
|
40981
|
+
return void 0;
|
|
40982
|
+
localDeploymentKey = Buffer.from(deploymentKeyBase64, "base64");
|
|
40983
|
+
return localDeploymentKey;
|
|
40984
|
+
}
|
|
40985
|
+
__name(getLocalDeploymentKey, "getLocalDeploymentKey");
|
|
40986
|
+
return /* @__PURE__ */ __name(async function getEncryptionKeyForRun(run, context2) {
|
|
40987
|
+
const runId = typeof run === "string" ? run : run.runId;
|
|
40988
|
+
const deploymentId = typeof run === "string" ? context2?.deploymentId : run.deploymentId;
|
|
40989
|
+
if (!deploymentId || deploymentId === currentDeploymentId) {
|
|
40990
|
+
const localKey = getLocalDeploymentKey();
|
|
40991
|
+
if (!localKey)
|
|
40992
|
+
return void 0;
|
|
40993
|
+
return deriveRunKey(localKey, projectId, runId);
|
|
40994
|
+
}
|
|
40995
|
+
return fetchRunKey(deploymentId, projectId, runId, { token });
|
|
40996
|
+
}, "getEncryptionKeyForRun");
|
|
40997
|
+
}
|
|
40998
|
+
__name(createGetEncryptionKeyForRun, "createGetEncryptionKeyForRun");
|
|
40912
40999
|
// ../../node_modules/.pnpm/@vercel+queue@0.0.0-alpha.38/node_modules/@vercel/queue/dist/web.mjs
|
|
40913
41000
|
var fs2 = __toESM(require("fs"), 1);
|
|
40914
41001
|
var path9 = __toESM(require("path"), 1);
|
|
40915
|
-
var
|
|
41002
|
+
var import_oidc3 = __toESM(require_dist(), 1);
|
|
40916
41003
|
var MessageNotFoundError2 = class extends Error {
|
|
40917
41004
|
static {
|
|
40918
41005
|
__name(this, "MessageNotFoundError");
|
|
@@ -41347,7 +41434,7 @@ var QueueClient2 = class {
|
|
|
41347
41434
|
if (this.providedToken) {
|
|
41348
41435
|
return this.providedToken;
|
|
41349
41436
|
}
|
|
41350
|
-
const token = await (0,
|
|
41437
|
+
const token = await (0, import_oidc3.getVercelOidcToken)();
|
|
41351
41438
|
if (!token) {
|
|
41352
41439
|
throw new Error("Failed to get OIDC token from Vercel Functions. Make sure you are running in a Vercel Function environment, or provide a token explicitly.\n\nTo set up your environment:\n1. Link your project: 'vercel link'\n2. Pull environment variables: 'vercel env pull'\n3. Run with environment: 'dotenv -e .env.local -- your-command'");
|
|
41353
41440
|
}
|
|
@@ -42217,7 +42304,7 @@ __name(handleCallback2, "handleCallback2");
|
|
|
42217
42304
|
// ../world-vercel/dist/utils.js
|
|
42218
42305
|
var import_node_os = __toESM(require("node:os"), 1);
|
|
42219
42306
|
var import_node_util2 = require("node:util");
|
|
42220
|
-
var
|
|
42307
|
+
var import_oidc4 = __toESM(require_dist(), 1);
|
|
42221
42308
|
// ../../node_modules/.pnpm/cbor-x@1.6.0/node_modules/cbor-x/decode.js
|
|
42222
42309
|
var decoder;
|
|
42223
42310
|
try {
|
|
@@ -44781,7 +44868,7 @@ var RpcSystem3 = SemanticConvention3("rpc.system");
|
|
|
44781
44868
|
var RpcService3 = SemanticConvention3("rpc.service");
|
|
44782
44869
|
var RpcMethod3 = SemanticConvention3("rpc.method");
|
|
44783
44870
|
// ../world-vercel/dist/version.js
|
|
44784
|
-
var version2 = "4.1.0-beta.
|
|
44871
|
+
var version2 = "4.1.0-beta.34";
|
|
44785
44872
|
// ../world-vercel/dist/utils.js
|
|
44786
44873
|
var WORKFLOW_SERVER_URL_OVERRIDE = "";
|
|
44787
44874
|
var DEFAULT_RESOLVE_DATA_OPTION2 = "all";
|
|
@@ -44864,7 +44951,7 @@ var getHeaders = /* @__PURE__ */ __name((config3, options) => {
|
|
|
44864
44951
|
async function getHttpConfig(config3) {
|
|
44865
44952
|
const { baseUrl, usingProxy } = getHttpUrl(config3);
|
|
44866
44953
|
const headers = getHeaders(config3, { usingProxy });
|
|
44867
|
-
const token = config3?.token ?? await (0,
|
|
44954
|
+
const token = config3?.token ?? await (0, import_oidc4.getVercelOidcToken)();
|
|
44868
44955
|
if (token) {
|
|
44869
44956
|
headers.set("Authorization", `Bearer ${token}`);
|
|
44870
44957
|
}
|
|
@@ -45681,10 +45768,12 @@ function createStreamer2(config3) {
|
|
|
45681
45768
|
__name(createStreamer2, "createStreamer");
|
|
45682
45769
|
// ../world-vercel/dist/index.js
|
|
45683
45770
|
function createVercelWorld(config3) {
|
|
45771
|
+
const projectId = config3?.projectConfig?.projectId || process.env.VERCEL_PROJECT_ID;
|
|
45684
45772
|
return {
|
|
45685
45773
|
...createQueue2(config3),
|
|
45686
45774
|
...createStorage2(config3),
|
|
45687
|
-
...createStreamer2(config3)
|
|
45775
|
+
...createStreamer2(config3),
|
|
45776
|
+
getEncryptionKeyForRun: createGetEncryptionKeyForRun(projectId, config3?.token)
|
|
45688
45777
|
};
|
|
45689
45778
|
}
|
|
45690
45779
|
__name(createVercelWorld, "createVercelWorld");
|
|
@@ -47513,11 +47602,15 @@ function extractTraceHeaders(traceCarrier) {
|
|
|
47513
47602
|
return headers;
|
|
47514
47603
|
}
|
|
47515
47604
|
__name(extractTraceHeaders, "extractTraceHeaders");
|
|
47516
|
-
async function handleSuspension({ suspension, world,
|
|
47605
|
+
async function handleSuspension({ suspension, world, run, span }) {
|
|
47606
|
+
const runId = run.runId;
|
|
47607
|
+
const workflowName = run.workflowName;
|
|
47608
|
+
const workflowStartedAt = run.startedAt ? +run.startedAt : Date.now();
|
|
47517
47609
|
const stepItems = suspension.steps.filter((item) => item.type === "step");
|
|
47518
47610
|
const hookItems = suspension.steps.filter((item) => item.type === "hook");
|
|
47519
47611
|
const waitItems = suspension.steps.filter((item) => item.type === "wait");
|
|
47520
|
-
const
|
|
47612
|
+
const rawKey = await world.getEncryptionKeyForRun?.(run);
|
|
47613
|
+
const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
|
|
47521
47614
|
const hookEvents = await Promise.all(hookItems.map(async (queueItem) => {
|
|
47522
47615
|
const hookMetadata = typeof queueItem.metadata === "undefined" ? void 0 : await dehydrateStepArguments(queueItem.metadata, runId, encryptionKey, suspension.globalThis);
|
|
47523
47616
|
return {
|
|
@@ -49337,7 +49430,7 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49337
49430
|
return { timeoutSeconds: retryRetryAfter };
|
|
49338
49431
|
}
|
|
49339
49432
|
if (err.status === 410) {
|
|
49340
|
-
|
|
49433
|
+
runtimeLogger.info(`Workflow run "${workflowRunId}" has already completed, skipping step "${stepId}": ${err.message}`);
|
|
49341
49434
|
return;
|
|
49342
49435
|
}
|
|
49343
49436
|
if (err.status === 409) {
|
|
@@ -49405,15 +49498,29 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49405
49498
|
stepName,
|
|
49406
49499
|
retryCount
|
|
49407
49500
|
});
|
|
49408
|
-
|
|
49409
|
-
|
|
49410
|
-
|
|
49411
|
-
|
|
49412
|
-
|
|
49413
|
-
|
|
49414
|
-
|
|
49501
|
+
try {
|
|
49502
|
+
await world.events.create(workflowRunId, {
|
|
49503
|
+
eventType: "step_failed",
|
|
49504
|
+
specVersion: SPEC_VERSION_CURRENT,
|
|
49505
|
+
correlationId: stepId,
|
|
49506
|
+
eventData: {
|
|
49507
|
+
error: errorMessage,
|
|
49508
|
+
stack: step.error?.stack
|
|
49509
|
+
}
|
|
49510
|
+
});
|
|
49511
|
+
}
|
|
49512
|
+
catch (err) {
|
|
49513
|
+
if (WorkflowAPIError.is(err) && err.status === 409) {
|
|
49514
|
+
runtimeLogger.warn("Tried failing step, but step has already finished.", {
|
|
49515
|
+
workflowRunId,
|
|
49516
|
+
stepId,
|
|
49517
|
+
stepName,
|
|
49518
|
+
message: err.message
|
|
49519
|
+
});
|
|
49520
|
+
return;
|
|
49415
49521
|
}
|
|
49416
|
-
|
|
49522
|
+
throw err;
|
|
49523
|
+
}
|
|
49417
49524
|
span?.setAttributes({
|
|
49418
49525
|
...StepStatus("failed"),
|
|
49419
49526
|
...StepRetryExhausted(true)
|
|
@@ -49432,7 +49539,8 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49432
49539
|
}
|
|
49433
49540
|
const stepStartedAt = step.startedAt;
|
|
49434
49541
|
const ops = [];
|
|
49435
|
-
const
|
|
49542
|
+
const rawKey = await world.getEncryptionKeyForRun?.(workflowRunId);
|
|
49543
|
+
const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
|
|
49436
49544
|
const hydratedInput = await trace2("step.hydrate", {}, async (hydrateSpan) => {
|
|
49437
49545
|
const startTime = Date.now();
|
|
49438
49546
|
const result2 = await hydrateStepArguments(step.input, workflowRunId, encryptionKey, ops);
|
|
@@ -49483,6 +49591,7 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49483
49591
|
if (!isAbortError)
|
|
49484
49592
|
throw err;
|
|
49485
49593
|
}));
|
|
49594
|
+
let stepCompleted409 = false;
|
|
49486
49595
|
const [, traceCarrier] = await Promise.all([
|
|
49487
49596
|
withServerErrorRetry(() => world.events.create(workflowRunId, {
|
|
49488
49597
|
eventType: "step_completed",
|
|
@@ -49491,9 +49600,24 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49491
49600
|
eventData: {
|
|
49492
49601
|
result
|
|
49493
49602
|
}
|
|
49494
|
-
}))
|
|
49603
|
+
})).catch((err) => {
|
|
49604
|
+
if (WorkflowAPIError.is(err) && err.status === 409) {
|
|
49605
|
+
runtimeLogger.warn("Tried completing step, but step has already finished.", {
|
|
49606
|
+
workflowRunId,
|
|
49607
|
+
stepId,
|
|
49608
|
+
stepName,
|
|
49609
|
+
message: err.message
|
|
49610
|
+
});
|
|
49611
|
+
stepCompleted409 = true;
|
|
49612
|
+
return;
|
|
49613
|
+
}
|
|
49614
|
+
throw err;
|
|
49615
|
+
}),
|
|
49495
49616
|
serializeTraceCarrier()
|
|
49496
49617
|
]);
|
|
49618
|
+
if (stepCompleted409) {
|
|
49619
|
+
return;
|
|
49620
|
+
}
|
|
49497
49621
|
span?.setAttributes({
|
|
49498
49622
|
...StepStatus("completed"),
|
|
49499
49623
|
...StepResultType(typeof result)
|
|
@@ -49547,15 +49671,29 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49547
49671
|
stepName,
|
|
49548
49672
|
errorStack: normalizedStack
|
|
49549
49673
|
});
|
|
49550
|
-
|
|
49551
|
-
|
|
49552
|
-
|
|
49553
|
-
|
|
49554
|
-
|
|
49555
|
-
|
|
49556
|
-
|
|
49674
|
+
try {
|
|
49675
|
+
await withServerErrorRetry(() => world.events.create(workflowRunId, {
|
|
49676
|
+
eventType: "step_failed",
|
|
49677
|
+
specVersion: SPEC_VERSION_CURRENT,
|
|
49678
|
+
correlationId: stepId,
|
|
49679
|
+
eventData: {
|
|
49680
|
+
error: normalizedError.message,
|
|
49681
|
+
stack: normalizedStack
|
|
49682
|
+
}
|
|
49683
|
+
}));
|
|
49684
|
+
}
|
|
49685
|
+
catch (stepFailErr) {
|
|
49686
|
+
if (WorkflowAPIError.is(stepFailErr) && stepFailErr.status === 409) {
|
|
49687
|
+
runtimeLogger.warn("Tried failing step, but step has already finished.", {
|
|
49688
|
+
workflowRunId,
|
|
49689
|
+
stepId,
|
|
49690
|
+
stepName,
|
|
49691
|
+
message: stepFailErr.message
|
|
49692
|
+
});
|
|
49693
|
+
return;
|
|
49557
49694
|
}
|
|
49558
|
-
|
|
49695
|
+
throw stepFailErr;
|
|
49696
|
+
}
|
|
49559
49697
|
span?.setAttributes({
|
|
49560
49698
|
...StepStatus("failed"),
|
|
49561
49699
|
...StepFatalError(true)
|
|
@@ -49578,15 +49716,29 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49578
49716
|
errorStack: normalizedStack
|
|
49579
49717
|
});
|
|
49580
49718
|
const errorMessage = `Step "${stepName}" failed after ${maxRetries2} ${pluralize("retry", "retries", maxRetries2)}: ${normalizedError.message}`;
|
|
49581
|
-
|
|
49582
|
-
|
|
49583
|
-
|
|
49584
|
-
|
|
49585
|
-
|
|
49586
|
-
|
|
49587
|
-
|
|
49719
|
+
try {
|
|
49720
|
+
await withServerErrorRetry(() => world.events.create(workflowRunId, {
|
|
49721
|
+
eventType: "step_failed",
|
|
49722
|
+
specVersion: SPEC_VERSION_CURRENT,
|
|
49723
|
+
correlationId: stepId,
|
|
49724
|
+
eventData: {
|
|
49725
|
+
error: errorMessage,
|
|
49726
|
+
stack: normalizedStack
|
|
49727
|
+
}
|
|
49728
|
+
}));
|
|
49729
|
+
}
|
|
49730
|
+
catch (stepFailErr) {
|
|
49731
|
+
if (WorkflowAPIError.is(stepFailErr) && stepFailErr.status === 409) {
|
|
49732
|
+
runtimeLogger.warn("Tried failing step, but step has already finished.", {
|
|
49733
|
+
workflowRunId,
|
|
49734
|
+
stepId,
|
|
49735
|
+
stepName,
|
|
49736
|
+
message: stepFailErr.message
|
|
49737
|
+
});
|
|
49738
|
+
return;
|
|
49588
49739
|
}
|
|
49589
|
-
|
|
49740
|
+
throw stepFailErr;
|
|
49741
|
+
}
|
|
49590
49742
|
span?.setAttributes({
|
|
49591
49743
|
...StepStatus("failed"),
|
|
49592
49744
|
...StepRetryExhausted(true)
|
|
@@ -49609,18 +49761,32 @@ var stepHandler = getWorldHandlers().createQueueHandler("__wkf_step_", async (me
|
|
|
49609
49761
|
errorStack: normalizedStack
|
|
49610
49762
|
});
|
|
49611
49763
|
}
|
|
49612
|
-
|
|
49613
|
-
|
|
49614
|
-
|
|
49615
|
-
|
|
49616
|
-
|
|
49617
|
-
|
|
49618
|
-
|
|
49619
|
-
|
|
49620
|
-
|
|
49764
|
+
try {
|
|
49765
|
+
await withServerErrorRetry(() => world.events.create(workflowRunId, {
|
|
49766
|
+
eventType: "step_retrying",
|
|
49767
|
+
specVersion: SPEC_VERSION_CURRENT,
|
|
49768
|
+
correlationId: stepId,
|
|
49769
|
+
eventData: {
|
|
49770
|
+
error: normalizedError.message,
|
|
49771
|
+
stack: normalizedStack,
|
|
49772
|
+
...RetryableError.is(err) && {
|
|
49773
|
+
retryAfter: err.retryAfter
|
|
49774
|
+
}
|
|
49621
49775
|
}
|
|
49776
|
+
}));
|
|
49777
|
+
}
|
|
49778
|
+
catch (stepRetryErr) {
|
|
49779
|
+
if (WorkflowAPIError.is(stepRetryErr) && stepRetryErr.status === 409) {
|
|
49780
|
+
runtimeLogger.warn("Tried retrying step, but step has already finished.", {
|
|
49781
|
+
workflowRunId,
|
|
49782
|
+
stepId,
|
|
49783
|
+
stepName,
|
|
49784
|
+
message: stepRetryErr.message
|
|
49785
|
+
});
|
|
49786
|
+
return;
|
|
49622
49787
|
}
|
|
49623
|
-
|
|
49788
|
+
throw stepRetryErr;
|
|
49789
|
+
}
|
|
49624
49790
|
const timeoutSeconds = Math.max(1, RetryableError.is(err) ? Math.ceil((+err.retryAfter.getTime() - Date.now()) / 1e3) : 1);
|
|
49625
49791
|
span?.setAttributes({
|
|
49626
49792
|
...StepRetryTimeoutSeconds(timeoutSeconds),
|
|
@@ -49674,8 +49840,8 @@ function workflowEntrypoint(workflowCode2) {
|
|
|
49674
49840
|
});
|
|
49675
49841
|
return await withThrottleRetry(async () => {
|
|
49676
49842
|
let workflowStartedAt = -1;
|
|
49843
|
+
let workflowRun = await world.runs.get(runId);
|
|
49677
49844
|
try {
|
|
49678
|
-
let workflowRun = await world.runs.get(runId);
|
|
49679
49845
|
if (workflowRun.status === "pending") {
|
|
49680
49846
|
const result2 = await world.events.create(runId, {
|
|
49681
49847
|
eventType: "run_started",
|
|
@@ -49729,7 +49895,8 @@ function workflowEntrypoint(workflowCode2) {
|
|
|
49729
49895
|
replaySpan?.setAttributes({
|
|
49730
49896
|
...WorkflowEventsCount(events.length)
|
|
49731
49897
|
});
|
|
49732
|
-
const
|
|
49898
|
+
const rawKey = await world.getEncryptionKeyForRun?.(workflowRun);
|
|
49899
|
+
const encryptionKey = rawKey ? await importKey(rawKey) : void 0;
|
|
49733
49900
|
return await runWorkflow(workflowCode2, workflowRun, events, encryptionKey);
|
|
49734
49901
|
});
|
|
49735
49902
|
try {
|
|
@@ -49767,9 +49934,7 @@ function workflowEntrypoint(workflowCode2) {
|
|
|
49767
49934
|
const result = await handleSuspension({
|
|
49768
49935
|
suspension: err,
|
|
49769
49936
|
world,
|
|
49770
|
-
|
|
49771
|
-
workflowName,
|
|
49772
|
-
workflowStartedAt,
|
|
49937
|
+
run: workflowRun,
|
|
49773
49938
|
span
|
|
49774
49939
|
});
|
|
49775
49940
|
if (result.timeoutSeconds !== void 0) {
|
|
@@ -50098,7 +50263,7 @@ function getWritable(options = {}) {
|
|
|
50098
50263
|
__name(getWritable, "getWritable");
|
|
50099
50264
|
|
|
50100
50265
|
// ../workflow/dist/stdlib.js
|
|
50101
|
-
var fetch = globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.1.0-beta.
|
|
50266
|
+
var fetch = globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//workflow@4.1.0-beta.59//fetch");
|
|
50102
50267
|
|
|
50103
50268
|
// ../../node_modules/.pnpm/zod@4.1.11/node_modules/zod/v4/core/core.js
|
|
50104
50269
|
var NEVER = Object.freeze({
|