@dudousxd/nestjs-durable-core 0.59.0 → 0.61.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/dist/index.cjs +176 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +91 -16
- package/dist/index.d.ts +91 -16
- package/dist/index.js +165 -53
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -173,10 +173,68 @@ function currentWorkflowCtx() {
|
|
|
173
173
|
}
|
|
174
174
|
__name(currentWorkflowCtx, "currentWorkflowCtx");
|
|
175
175
|
|
|
176
|
+
// src/ambient-step.ts
|
|
177
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "node:async_hooks";
|
|
178
|
+
var STORAGE_KEY2 = Symbol.for("nestjs-durable:ambient-step-logger");
|
|
179
|
+
var globalRef2 = globalThis;
|
|
180
|
+
if (!globalRef2[STORAGE_KEY2]) {
|
|
181
|
+
globalRef2[STORAGE_KEY2] = new AsyncLocalStorage2();
|
|
182
|
+
}
|
|
183
|
+
var storage2 = globalRef2[STORAGE_KEY2];
|
|
184
|
+
function runInStepLogger(logger, fn) {
|
|
185
|
+
return storage2.run(logger, fn);
|
|
186
|
+
}
|
|
187
|
+
__name(runInStepLogger, "runInStepLogger");
|
|
188
|
+
function currentStep() {
|
|
189
|
+
return storage2.getStore();
|
|
190
|
+
}
|
|
191
|
+
__name(currentStep, "currentStep");
|
|
192
|
+
function log(level, message, data) {
|
|
193
|
+
currentStep()?.[level](message, data);
|
|
194
|
+
}
|
|
195
|
+
__name(log, "log");
|
|
196
|
+
function debug(message, data) {
|
|
197
|
+
currentStep()?.debug(message, data);
|
|
198
|
+
}
|
|
199
|
+
__name(debug, "debug");
|
|
200
|
+
function info(message, data) {
|
|
201
|
+
currentStep()?.info(message, data);
|
|
202
|
+
}
|
|
203
|
+
__name(info, "info");
|
|
204
|
+
function warn(message, data) {
|
|
205
|
+
currentStep()?.warn(message, data);
|
|
206
|
+
}
|
|
207
|
+
__name(warn, "warn");
|
|
208
|
+
function error(message, data) {
|
|
209
|
+
currentStep()?.error(message, data);
|
|
210
|
+
}
|
|
211
|
+
__name(error, "error");
|
|
212
|
+
function sub(name, status, message, data) {
|
|
213
|
+
currentStep()?.sub(name, status, message, data);
|
|
214
|
+
}
|
|
215
|
+
__name(sub, "sub");
|
|
216
|
+
function subEvent(e) {
|
|
217
|
+
currentStep()?.subEvent(e);
|
|
218
|
+
}
|
|
219
|
+
__name(subEvent, "subEvent");
|
|
220
|
+
var noopSubProcessHandle = {
|
|
221
|
+
phase: /* @__PURE__ */ __name(() => noopSubProcessHandle, "phase"),
|
|
222
|
+
skip: /* @__PURE__ */ __name(() => {
|
|
223
|
+
}, "skip"),
|
|
224
|
+
fail: /* @__PURE__ */ __name(() => {
|
|
225
|
+
}, "fail")
|
|
226
|
+
};
|
|
227
|
+
function subProcess(name, body, opts) {
|
|
228
|
+
const logger = currentStep();
|
|
229
|
+
if (!logger) return Promise.resolve(body(noopSubProcessHandle));
|
|
230
|
+
return logger.subProcess(name, body, opts);
|
|
231
|
+
}
|
|
232
|
+
__name(subProcess, "subProcess");
|
|
233
|
+
|
|
176
234
|
// src/control-flow-signal.ts
|
|
177
235
|
var CONTROL_FLOW_SIGNAL = Symbol.for("aviary:durable:control-flow");
|
|
178
|
-
function isWorkflowControlFlowSignal(
|
|
179
|
-
return typeof
|
|
236
|
+
function isWorkflowControlFlowSignal(error2) {
|
|
237
|
+
return typeof error2 === "object" && error2 !== null && error2[CONTROL_FLOW_SIGNAL] === true;
|
|
180
238
|
}
|
|
181
239
|
__name(isWorkflowControlFlowSignal, "isWorkflowControlFlowSignal");
|
|
182
240
|
|
|
@@ -313,11 +371,11 @@ __name(workflowName, "workflowName");
|
|
|
313
371
|
|
|
314
372
|
// src/durable-workflow.ts
|
|
315
373
|
var BINDINGS_KEY = Symbol.for("nestjs-durable:workflow-class-bindings");
|
|
316
|
-
var
|
|
317
|
-
if (!
|
|
318
|
-
|
|
374
|
+
var globalRef3 = globalThis;
|
|
375
|
+
if (!globalRef3[BINDINGS_KEY]) {
|
|
376
|
+
globalRef3[BINDINGS_KEY] = /* @__PURE__ */ new WeakMap();
|
|
319
377
|
}
|
|
320
|
-
var bindings =
|
|
378
|
+
var bindings = globalRef3[BINDINGS_KEY];
|
|
321
379
|
function bindWorkflowClass(ctor, client) {
|
|
322
380
|
bindings.set(ctor, client);
|
|
323
381
|
}
|
|
@@ -448,7 +506,7 @@ function createStepLogger(events, now) {
|
|
|
448
506
|
data
|
|
449
507
|
}
|
|
450
508
|
}), "push");
|
|
451
|
-
const
|
|
509
|
+
const subEvent2 = /* @__PURE__ */ __name((e) => events.push({
|
|
452
510
|
at: now(),
|
|
453
511
|
level: e.status === "failed" ? "error" : e.status === "skipped" ? "warn" : "info",
|
|
454
512
|
message: e.message ?? e.phase ?? e.name,
|
|
@@ -467,7 +525,7 @@ function createStepLogger(events, now) {
|
|
|
467
525
|
data: e.data
|
|
468
526
|
}
|
|
469
527
|
}), "subEvent");
|
|
470
|
-
const
|
|
528
|
+
const subProcess2 = /* @__PURE__ */ __name(async (name, body, opts) => {
|
|
471
529
|
const id = opts?.id ?? globalThis.crypto.randomUUID();
|
|
472
530
|
const group = opts?.group;
|
|
473
531
|
const start = now();
|
|
@@ -479,7 +537,7 @@ function createStepLogger(events, now) {
|
|
|
479
537
|
const emit = /* @__PURE__ */ __name((status, message, data) => {
|
|
480
538
|
if (terminal) return;
|
|
481
539
|
terminal = true;
|
|
482
|
-
|
|
540
|
+
subEvent2({
|
|
483
541
|
id,
|
|
484
542
|
name,
|
|
485
543
|
group,
|
|
@@ -490,7 +548,7 @@ function createStepLogger(events, now) {
|
|
|
490
548
|
}, "emit");
|
|
491
549
|
const handle = {
|
|
492
550
|
phase: /* @__PURE__ */ __name((phase, data) => {
|
|
493
|
-
if (!terminal)
|
|
551
|
+
if (!terminal) subEvent2({
|
|
494
552
|
id,
|
|
495
553
|
name,
|
|
496
554
|
group,
|
|
@@ -528,8 +586,8 @@ function createStepLogger(events, now) {
|
|
|
528
586
|
data
|
|
529
587
|
}
|
|
530
588
|
}), "sub"),
|
|
531
|
-
subEvent,
|
|
532
|
-
subProcess
|
|
589
|
+
subEvent: subEvent2,
|
|
590
|
+
subProcess: subProcess2
|
|
533
591
|
};
|
|
534
592
|
}
|
|
535
593
|
__name(createStepLogger, "createStepLogger");
|
|
@@ -563,7 +621,8 @@ async function runStepHandler(task, handler) {
|
|
|
563
621
|
events
|
|
564
622
|
} : result, "withEvents");
|
|
565
623
|
try {
|
|
566
|
-
const
|
|
624
|
+
const logger = createStepLogger(events, Date.now);
|
|
625
|
+
const output = await runInStepLogger(logger, () => handler(task.input, logger));
|
|
567
626
|
return withEvents({
|
|
568
627
|
...base,
|
|
569
628
|
status: "completed",
|
|
@@ -1613,7 +1672,10 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
|
|
|
1613
1672
|
seq: current,
|
|
1614
1673
|
attempt
|
|
1615
1674
|
};
|
|
1616
|
-
const body = /* @__PURE__ */ __name(() =>
|
|
1675
|
+
const body = /* @__PURE__ */ __name(() => {
|
|
1676
|
+
const logger = createStepLogger(events, host.clock);
|
|
1677
|
+
return runInStepLogger(logger, () => fn(logger));
|
|
1678
|
+
}, "body");
|
|
1617
1679
|
const output = host.interceptStep ? await host.interceptStep(invocation, body) : await body();
|
|
1618
1680
|
await host.completeStep({
|
|
1619
1681
|
runId,
|
|
@@ -2915,13 +2977,13 @@ var WorkflowEngine = class {
|
|
|
2915
2977
|
];
|
|
2916
2978
|
for (const run of inflight) {
|
|
2917
2979
|
if (run.createdAt.getTime() > deadline) continue;
|
|
2918
|
-
const
|
|
2980
|
+
const error2 = {
|
|
2919
2981
|
message: "execution timeout",
|
|
2920
2982
|
code: "execution_timeout"
|
|
2921
2983
|
};
|
|
2922
2984
|
await this.store.updateRun(run.id, {
|
|
2923
2985
|
status: "cancelled",
|
|
2924
|
-
error,
|
|
2986
|
+
error: error2,
|
|
2925
2987
|
updatedAt: /* @__PURE__ */ new Date()
|
|
2926
2988
|
});
|
|
2927
2989
|
this.emit({
|
|
@@ -2929,7 +2991,7 @@ var WorkflowEngine = class {
|
|
|
2929
2991
|
runId: run.id,
|
|
2930
2992
|
workflow: run.workflow,
|
|
2931
2993
|
namespace: run.namespace,
|
|
2932
|
-
error
|
|
2994
|
+
error: error2
|
|
2933
2995
|
});
|
|
2934
2996
|
}
|
|
2935
2997
|
}
|
|
@@ -2944,6 +3006,22 @@ var WorkflowEngine = class {
|
|
|
2944
3006
|
for (const run of await this.store.listIncompleteRuns(this.namespace)) {
|
|
2945
3007
|
const acquired = await this.store.tryLockRun(run.id, this.instanceId, nowMs + this.leaseMs, nowMs);
|
|
2946
3008
|
if (!acquired) continue;
|
|
3009
|
+
if (run.status === "running") {
|
|
3010
|
+
const dispatched = await this.inFlightRemoteStep(run.id);
|
|
3011
|
+
if (dispatched) {
|
|
3012
|
+
await this.store.updateRun(run.id, {
|
|
3013
|
+
status: "suspended",
|
|
3014
|
+
wakeAt: this.reconcileWakeAt(dispatched.wakeAt ?? void 0),
|
|
3015
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
3016
|
+
});
|
|
3017
|
+
await this.store.releaseRunLock(run.id);
|
|
3018
|
+
results.push({
|
|
3019
|
+
runId: run.id,
|
|
3020
|
+
status: "suspended"
|
|
3021
|
+
});
|
|
3022
|
+
continue;
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
2947
3025
|
const settled = await this.countRecovery(run);
|
|
2948
3026
|
if (settled) {
|
|
2949
3027
|
results.push(settled);
|
|
@@ -2965,6 +3043,16 @@ var WorkflowEngine = class {
|
|
|
2965
3043
|
return results;
|
|
2966
3044
|
}
|
|
2967
3045
|
/**
|
|
3046
|
+
* The remote step this run dispatched and is still awaiting a result for, if any — the signature
|
|
3047
|
+
* that tells {@link recoverIncomplete} "this run's work is ON THE TRANSPORT, not in a crashed
|
|
3048
|
+
* process". A `pending` remote checkpoint is written BEFORE the dispatch and settled by the
|
|
3049
|
+
* worker's result, so its presence is the durable marker of an in-flight dispatched step.
|
|
3050
|
+
*/
|
|
3051
|
+
async inFlightRemoteStep(runId) {
|
|
3052
|
+
const checkpoints = await this.store.listCheckpoints(runId);
|
|
3053
|
+
return checkpoints.find((cp) => cp.kind === "remote" && cp.status === "pending");
|
|
3054
|
+
}
|
|
3055
|
+
/**
|
|
2968
3056
|
* Per-recovery bookkeeping (called once the lease is held): count the attempt, or — past
|
|
2969
3057
|
* `maxRecoveryAttempts` — move a poison pill to the `dead` dead-letter state. Returns a terminal
|
|
2970
3058
|
* result to skip the resume, or `undefined` to proceed.
|
|
@@ -2972,13 +3060,13 @@ var WorkflowEngine = class {
|
|
|
2972
3060
|
async countRecovery(run) {
|
|
2973
3061
|
const attempts = (run.recoveryAttempts ?? 0) + 1;
|
|
2974
3062
|
if (this.maxRecoveryAttempts != null && attempts > this.maxRecoveryAttempts) {
|
|
2975
|
-
const
|
|
3063
|
+
const error2 = {
|
|
2976
3064
|
message: `run exceeded maxRecoveryAttempts (${this.maxRecoveryAttempts}) \u2014 moved to dead-letter`,
|
|
2977
3065
|
code: "max_recovery_attempts"
|
|
2978
3066
|
};
|
|
2979
3067
|
await this.store.updateRun(run.id, {
|
|
2980
3068
|
status: "dead",
|
|
2981
|
-
error,
|
|
3069
|
+
error: error2,
|
|
2982
3070
|
updatedAt: /* @__PURE__ */ new Date()
|
|
2983
3071
|
});
|
|
2984
3072
|
await this.store.releaseRunLock(run.id);
|
|
@@ -2987,18 +3075,18 @@ var WorkflowEngine = class {
|
|
|
2987
3075
|
runId: run.id,
|
|
2988
3076
|
workflow: run.workflow,
|
|
2989
3077
|
namespace: run.namespace,
|
|
2990
|
-
error
|
|
3078
|
+
error: error2
|
|
2991
3079
|
});
|
|
2992
3080
|
this.notifyDead({
|
|
2993
3081
|
...run,
|
|
2994
3082
|
status: "dead",
|
|
2995
|
-
error,
|
|
3083
|
+
error: error2,
|
|
2996
3084
|
recoveryAttempts: attempts
|
|
2997
3085
|
});
|
|
2998
3086
|
return {
|
|
2999
3087
|
runId: run.id,
|
|
3000
3088
|
status: "dead",
|
|
3001
|
-
error
|
|
3089
|
+
error: error2
|
|
3002
3090
|
};
|
|
3003
3091
|
}
|
|
3004
3092
|
await this.store.updateRun(run.id, {
|
|
@@ -3119,7 +3207,8 @@ var WorkflowEngine = class {
|
|
|
3119
3207
|
seen.add(runId);
|
|
3120
3208
|
const run = await this.store.getRun(runId);
|
|
3121
3209
|
if (!run) return null;
|
|
3122
|
-
|
|
3210
|
+
const resurrecting = run.status === "failed" || run.status === "dead";
|
|
3211
|
+
if (resurrecting) {
|
|
3123
3212
|
const isFailureCompletion = /* @__PURE__ */ __name((v) => typeof v === "object" && v !== null && v.ok === false, "isFailureCompletion");
|
|
3124
3213
|
for (const cp of await this.store.listCheckpoints(runId)) {
|
|
3125
3214
|
if (cp.status === "failed") {
|
|
@@ -3162,6 +3251,9 @@ var WorkflowEngine = class {
|
|
|
3162
3251
|
await this.store.updateRun(runId, {
|
|
3163
3252
|
status: "pending",
|
|
3164
3253
|
error: void 0,
|
|
3254
|
+
...resurrecting ? {
|
|
3255
|
+
recoveryAttempts: 0
|
|
3256
|
+
} : {},
|
|
3165
3257
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3166
3258
|
});
|
|
3167
3259
|
await this.runDispatcher.dispatch(runId);
|
|
@@ -3174,9 +3266,11 @@ var WorkflowEngine = class {
|
|
|
3174
3266
|
* Explicitly re-dispatch every remote step of `runId` stuck `pending` — the OPERATOR escape hatch for
|
|
3175
3267
|
* a run whose dispatched step job was LOST (worker crashed with no result, or a transport that dropped
|
|
3176
3268
|
* the job). No automatic recovery re-drives these: a reconcile re-drive re-suspends a still-pending
|
|
3177
|
-
* step by design (unless `remoteRedispatchMs` is set), `recoverIncomplete`
|
|
3178
|
-
*
|
|
3179
|
-
*
|
|
3269
|
+
* step by design (unless `remoteRedispatchMs` is set), `recoverIncomplete` explicitly SKIPS a run with
|
|
3270
|
+
* an in-flight `pending` remote step (it re-asserts the durably-suspended invariant instead of counting
|
|
3271
|
+
* a recovery attempt — see there), and `requeue` just replays back to the pending guard. This
|
|
3272
|
+
* re-enqueues the same `stepId` so the (idempotent) step re-runs and its result resumes the run.
|
|
3273
|
+
* Safe to call on a healthy run — it re-runs
|
|
3180
3274
|
* only in-flight `pending` remote steps, which are idempotent by the durable contract. Returns the
|
|
3181
3275
|
* run's current status (with the count re-dispatched), or null if the run is unknown.
|
|
3182
3276
|
*/
|
|
@@ -3468,10 +3562,10 @@ var WorkflowEngine = class {
|
|
|
3468
3562
|
});
|
|
3469
3563
|
}
|
|
3470
3564
|
/** Report that a `ctx.task` failed — the run resumes and throws a FatalError at the task. */
|
|
3471
|
-
async failTask(runId, name,
|
|
3565
|
+
async failTask(runId, name, error2) {
|
|
3472
3566
|
return this.signal(`task:${runId}:${name}`, {
|
|
3473
3567
|
ok: false,
|
|
3474
|
-
error
|
|
3568
|
+
error: error2
|
|
3475
3569
|
});
|
|
3476
3570
|
}
|
|
3477
3571
|
/**
|
|
@@ -3553,12 +3647,12 @@ var WorkflowEngine = class {
|
|
|
3553
3647
|
status: "cancelling"
|
|
3554
3648
|
};
|
|
3555
3649
|
}
|
|
3556
|
-
const
|
|
3650
|
+
const error2 = {
|
|
3557
3651
|
message: "cancelled"
|
|
3558
3652
|
};
|
|
3559
3653
|
await this.store.updateRun(runId, {
|
|
3560
3654
|
status: "cancelled",
|
|
3561
|
-
error,
|
|
3655
|
+
error: error2,
|
|
3562
3656
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3563
3657
|
});
|
|
3564
3658
|
this.emit({
|
|
@@ -3566,7 +3660,7 @@ var WorkflowEngine = class {
|
|
|
3566
3660
|
runId,
|
|
3567
3661
|
workflow: run.workflow,
|
|
3568
3662
|
namespace: run.namespace,
|
|
3569
|
-
error
|
|
3663
|
+
error: error2
|
|
3570
3664
|
});
|
|
3571
3665
|
await this.cancelChildren(runId, opts);
|
|
3572
3666
|
this.notifyCancelled(runId);
|
|
@@ -3581,7 +3675,7 @@ var WorkflowEngine = class {
|
|
|
3581
3675
|
return {
|
|
3582
3676
|
runId,
|
|
3583
3677
|
status: "cancelled",
|
|
3584
|
-
error
|
|
3678
|
+
error: error2
|
|
3585
3679
|
};
|
|
3586
3680
|
}
|
|
3587
3681
|
/**
|
|
@@ -3976,12 +4070,12 @@ var WorkflowEngine = class {
|
|
|
3976
4070
|
}
|
|
3977
4071
|
async runRemoteExecution(run, registered) {
|
|
3978
4072
|
if (run.status === "cancelling") {
|
|
3979
|
-
const
|
|
4073
|
+
const error2 = {
|
|
3980
4074
|
message: "cancelled"
|
|
3981
4075
|
};
|
|
3982
4076
|
await this.store.updateRun(run.id, {
|
|
3983
4077
|
status: "cancelled",
|
|
3984
|
-
error,
|
|
4078
|
+
error: error2,
|
|
3985
4079
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3986
4080
|
});
|
|
3987
4081
|
this.emit({
|
|
@@ -3989,7 +4083,7 @@ var WorkflowEngine = class {
|
|
|
3989
4083
|
runId: run.id,
|
|
3990
4084
|
workflow: run.workflow,
|
|
3991
4085
|
namespace: run.namespace,
|
|
3992
|
-
error
|
|
4086
|
+
error: error2
|
|
3993
4087
|
});
|
|
3994
4088
|
this.notifyCancelled(run.id);
|
|
3995
4089
|
if (this.controlPlane) {
|
|
@@ -4003,7 +4097,7 @@ var WorkflowEngine = class {
|
|
|
4003
4097
|
return {
|
|
4004
4098
|
runId: run.id,
|
|
4005
4099
|
status: "cancelled",
|
|
4006
|
-
error
|
|
4100
|
+
error: error2
|
|
4007
4101
|
};
|
|
4008
4102
|
}
|
|
4009
4103
|
const remote = registered.remote;
|
|
@@ -4082,13 +4176,13 @@ var WorkflowEngine = class {
|
|
|
4082
4176
|
status: "running"
|
|
4083
4177
|
};
|
|
4084
4178
|
}
|
|
4085
|
-
const
|
|
4179
|
+
const error2 = {
|
|
4086
4180
|
message: err instanceof Error ? err.message : String(err),
|
|
4087
4181
|
stack: err instanceof Error ? err.stack : void 0
|
|
4088
4182
|
};
|
|
4089
4183
|
await this.store.updateRun(run.id, {
|
|
4090
4184
|
status: "failed",
|
|
4091
|
-
error,
|
|
4185
|
+
error: error2,
|
|
4092
4186
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4093
4187
|
});
|
|
4094
4188
|
this.emit({
|
|
@@ -4096,12 +4190,12 @@ var WorkflowEngine = class {
|
|
|
4096
4190
|
runId: run.id,
|
|
4097
4191
|
workflow: run.workflow,
|
|
4098
4192
|
namespace: run.namespace,
|
|
4099
|
-
error
|
|
4193
|
+
error: error2
|
|
4100
4194
|
});
|
|
4101
4195
|
return {
|
|
4102
4196
|
runId: run.id,
|
|
4103
4197
|
status: "failed",
|
|
4104
|
-
error
|
|
4198
|
+
error: error2
|
|
4105
4199
|
};
|
|
4106
4200
|
}
|
|
4107
4201
|
return this.applyDecision(run, decision);
|
|
@@ -4366,12 +4460,12 @@ var WorkflowEngine = class {
|
|
|
4366
4460
|
status: "cancelling"
|
|
4367
4461
|
};
|
|
4368
4462
|
this.cancelRequested.delete(run.id);
|
|
4369
|
-
const
|
|
4463
|
+
const error2 = {
|
|
4370
4464
|
message: "cancelled"
|
|
4371
4465
|
};
|
|
4372
4466
|
await this.store.updateRun(run.id, {
|
|
4373
4467
|
status: "cancelled",
|
|
4374
|
-
error,
|
|
4468
|
+
error: error2,
|
|
4375
4469
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4376
4470
|
});
|
|
4377
4471
|
this.emit({
|
|
@@ -4379,12 +4473,12 @@ var WorkflowEngine = class {
|
|
|
4379
4473
|
runId: run.id,
|
|
4380
4474
|
workflow: run.workflow,
|
|
4381
4475
|
namespace: run.namespace,
|
|
4382
|
-
error
|
|
4476
|
+
error: error2
|
|
4383
4477
|
});
|
|
4384
4478
|
return {
|
|
4385
4479
|
runId: run.id,
|
|
4386
4480
|
status: "cancelled",
|
|
4387
|
-
error
|
|
4481
|
+
error: error2
|
|
4388
4482
|
};
|
|
4389
4483
|
}
|
|
4390
4484
|
/** The run body, lease held + renewed by {@link execute}. */
|
|
@@ -4485,7 +4579,7 @@ var WorkflowEngine = class {
|
|
|
4485
4579
|
if (this.cancelRequested.has(run.id)) {
|
|
4486
4580
|
return this.compensateAndCancel(run, compensations, replay);
|
|
4487
4581
|
}
|
|
4488
|
-
const
|
|
4582
|
+
const error2 = {
|
|
4489
4583
|
message: err instanceof Error ? err.message : String(err),
|
|
4490
4584
|
stack: err instanceof Error ? err.stack : void 0
|
|
4491
4585
|
};
|
|
@@ -4496,7 +4590,7 @@ var WorkflowEngine = class {
|
|
|
4496
4590
|
});
|
|
4497
4591
|
return this.settleRun(run, {
|
|
4498
4592
|
kind: "failed",
|
|
4499
|
-
error
|
|
4593
|
+
error: error2
|
|
4500
4594
|
});
|
|
4501
4595
|
} finally {
|
|
4502
4596
|
await this.store.releaseRunLock(run.id);
|
|
@@ -4585,7 +4679,7 @@ var WorkflowEngine = class {
|
|
|
4585
4679
|
return;
|
|
4586
4680
|
} catch (err) {
|
|
4587
4681
|
if (attempt >= this.compensationRetries) {
|
|
4588
|
-
const
|
|
4682
|
+
const error2 = {
|
|
4589
4683
|
message: err instanceof Error ? err.message : String(err)
|
|
4590
4684
|
};
|
|
4591
4685
|
this.emit({
|
|
@@ -4594,7 +4688,7 @@ var WorkflowEngine = class {
|
|
|
4594
4688
|
workflow: run.workflow,
|
|
4595
4689
|
name,
|
|
4596
4690
|
kind: "local",
|
|
4597
|
-
error,
|
|
4691
|
+
error: error2,
|
|
4598
4692
|
durationMs: Date.now() - startedAt.getTime()
|
|
4599
4693
|
});
|
|
4600
4694
|
const cp = stepCheckpoint({
|
|
@@ -4604,7 +4698,7 @@ var WorkflowEngine = class {
|
|
|
4604
4698
|
kind: "local",
|
|
4605
4699
|
status: "failed",
|
|
4606
4700
|
attempts: attempt,
|
|
4607
|
-
error,
|
|
4701
|
+
error: error2,
|
|
4608
4702
|
enqueuedAt,
|
|
4609
4703
|
startedAt,
|
|
4610
4704
|
finishedAt: /* @__PURE__ */ new Date()
|
|
@@ -4860,14 +4954,14 @@ var WorkflowEngine = class {
|
|
|
4860
4954
|
error: current.error
|
|
4861
4955
|
};
|
|
4862
4956
|
}
|
|
4863
|
-
const
|
|
4957
|
+
const error2 = {
|
|
4864
4958
|
message: blocked.reason,
|
|
4865
4959
|
code: blocked.code,
|
|
4866
4960
|
retryable: true
|
|
4867
4961
|
};
|
|
4868
4962
|
await this.store.updateRun(run.id, {
|
|
4869
4963
|
status: "blocked",
|
|
4870
|
-
error,
|
|
4964
|
+
error: error2,
|
|
4871
4965
|
wakeAt: this.clock() + this.blockedPollMs,
|
|
4872
4966
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4873
4967
|
});
|
|
@@ -4876,7 +4970,7 @@ var WorkflowEngine = class {
|
|
|
4876
4970
|
runId: run.id,
|
|
4877
4971
|
workflow: run.workflow,
|
|
4878
4972
|
namespace: run.namespace,
|
|
4879
|
-
error,
|
|
4973
|
+
error: error2,
|
|
4880
4974
|
requires: blocked.requires,
|
|
4881
4975
|
diagnostics: blocked.diagnostics
|
|
4882
4976
|
});
|
|
@@ -4884,7 +4978,7 @@ var WorkflowEngine = class {
|
|
|
4884
4978
|
return {
|
|
4885
4979
|
runId: run.id,
|
|
4886
4980
|
status: "blocked",
|
|
4887
|
-
error
|
|
4981
|
+
error: error2
|
|
4888
4982
|
};
|
|
4889
4983
|
}
|
|
4890
4984
|
/** Runs parked `blocked` whose recovery poll is due (`wakeAt <= nowMs`), namespace-scoped like
|
|
@@ -5269,6 +5363,13 @@ var TERMINAL_RUN_STATUSES = [
|
|
|
5269
5363
|
"dead"
|
|
5270
5364
|
];
|
|
5271
5365
|
|
|
5366
|
+
// src/run-gateway.ts
|
|
5367
|
+
var RunGateway = class {
|
|
5368
|
+
static {
|
|
5369
|
+
__name(this, "RunGateway");
|
|
5370
|
+
}
|
|
5371
|
+
};
|
|
5372
|
+
|
|
5272
5373
|
// src/codec-state-store.ts
|
|
5273
5374
|
var CodecStateStore = class {
|
|
5274
5375
|
static {
|
|
@@ -6074,6 +6175,7 @@ export {
|
|
|
6074
6175
|
RemoteStepTimeout,
|
|
6075
6176
|
RemoteWorkflowExecutor,
|
|
6076
6177
|
RemoteWorkflowTimeout,
|
|
6178
|
+
RunGateway,
|
|
6077
6179
|
STATE_STORE,
|
|
6078
6180
|
STATE_STORE_CANONICAL,
|
|
6079
6181
|
SignalTimeoutError,
|
|
@@ -6096,8 +6198,11 @@ export {
|
|
|
6096
6198
|
collectMetrics,
|
|
6097
6199
|
controlPlaneDescriptor,
|
|
6098
6200
|
createStepLogger,
|
|
6201
|
+
currentStep,
|
|
6099
6202
|
currentWorkflowCtx,
|
|
6203
|
+
debug,
|
|
6100
6204
|
descriptorHash,
|
|
6205
|
+
error,
|
|
6101
6206
|
eventMatchOf,
|
|
6102
6207
|
eventMatches,
|
|
6103
6208
|
eventNameOf,
|
|
@@ -6105,9 +6210,11 @@ export {
|
|
|
6105
6210
|
eventToken,
|
|
6106
6211
|
heartbeatStatus,
|
|
6107
6212
|
indexWaitersByRun,
|
|
6213
|
+
info,
|
|
6108
6214
|
isEventToken,
|
|
6109
6215
|
isLegacyDescriptor,
|
|
6110
6216
|
isWorkflowControlFlowSignal,
|
|
6217
|
+
log,
|
|
6111
6218
|
matchesAttributes,
|
|
6112
6219
|
missingCapabilities,
|
|
6113
6220
|
negotiate,
|
|
@@ -6120,6 +6227,7 @@ export {
|
|
|
6120
6227
|
requiredCapabilities,
|
|
6121
6228
|
resolveRouting,
|
|
6122
6229
|
resolveRunWaiting,
|
|
6230
|
+
runInStepLogger,
|
|
6123
6231
|
runInWorkflowCtx,
|
|
6124
6232
|
runSchedules,
|
|
6125
6233
|
runStepHandler,
|
|
@@ -6129,7 +6237,11 @@ export {
|
|
|
6129
6237
|
stepConfigOf,
|
|
6130
6238
|
stepId,
|
|
6131
6239
|
stepNameOf,
|
|
6240
|
+
sub,
|
|
6241
|
+
subEvent,
|
|
6242
|
+
subProcess,
|
|
6132
6243
|
tenantGroup,
|
|
6244
|
+
warn,
|
|
6133
6245
|
workflowName
|
|
6134
6246
|
};
|
|
6135
6247
|
//# sourceMappingURL=index.js.map
|