@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.cjs
CHANGED
|
@@ -48,6 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
RemoteStepTimeout: () => RemoteStepTimeout,
|
|
49
49
|
RemoteWorkflowExecutor: () => RemoteWorkflowExecutor,
|
|
50
50
|
RemoteWorkflowTimeout: () => RemoteWorkflowTimeout,
|
|
51
|
+
RunGateway: () => RunGateway,
|
|
51
52
|
STATE_STORE: () => STATE_STORE,
|
|
52
53
|
STATE_STORE_CANONICAL: () => STATE_STORE_CANONICAL,
|
|
53
54
|
SignalTimeoutError: () => SignalTimeoutError,
|
|
@@ -70,8 +71,11 @@ __export(index_exports, {
|
|
|
70
71
|
collectMetrics: () => collectMetrics,
|
|
71
72
|
controlPlaneDescriptor: () => controlPlaneDescriptor,
|
|
72
73
|
createStepLogger: () => createStepLogger,
|
|
74
|
+
currentStep: () => currentStep,
|
|
73
75
|
currentWorkflowCtx: () => currentWorkflowCtx,
|
|
76
|
+
debug: () => debug,
|
|
74
77
|
descriptorHash: () => descriptorHash,
|
|
78
|
+
error: () => error,
|
|
75
79
|
eventMatchOf: () => eventMatchOf,
|
|
76
80
|
eventMatches: () => eventMatches,
|
|
77
81
|
eventNameOf: () => eventNameOf,
|
|
@@ -79,9 +83,11 @@ __export(index_exports, {
|
|
|
79
83
|
eventToken: () => eventToken,
|
|
80
84
|
heartbeatStatus: () => heartbeatStatus,
|
|
81
85
|
indexWaitersByRun: () => indexWaitersByRun,
|
|
86
|
+
info: () => info,
|
|
82
87
|
isEventToken: () => isEventToken,
|
|
83
88
|
isLegacyDescriptor: () => isLegacyDescriptor,
|
|
84
89
|
isWorkflowControlFlowSignal: () => isWorkflowControlFlowSignal,
|
|
90
|
+
log: () => log,
|
|
85
91
|
matchesAttributes: () => matchesAttributes,
|
|
86
92
|
missingCapabilities: () => missingCapabilities,
|
|
87
93
|
negotiate: () => negotiate,
|
|
@@ -94,6 +100,7 @@ __export(index_exports, {
|
|
|
94
100
|
requiredCapabilities: () => requiredCapabilities,
|
|
95
101
|
resolveRouting: () => resolveRouting,
|
|
96
102
|
resolveRunWaiting: () => resolveRunWaiting,
|
|
103
|
+
runInStepLogger: () => runInStepLogger,
|
|
97
104
|
runInWorkflowCtx: () => runInWorkflowCtx,
|
|
98
105
|
runSchedules: () => runSchedules,
|
|
99
106
|
runStepHandler: () => runStepHandler,
|
|
@@ -103,7 +110,11 @@ __export(index_exports, {
|
|
|
103
110
|
stepConfigOf: () => stepConfigOf,
|
|
104
111
|
stepId: () => stepId,
|
|
105
112
|
stepNameOf: () => stepNameOf,
|
|
113
|
+
sub: () => sub,
|
|
114
|
+
subEvent: () => subEvent,
|
|
115
|
+
subProcess: () => subProcess,
|
|
106
116
|
tenantGroup: () => tenantGroup,
|
|
117
|
+
warn: () => warn,
|
|
107
118
|
workflowName: () => workflowName
|
|
108
119
|
});
|
|
109
120
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -280,10 +291,68 @@ function currentWorkflowCtx() {
|
|
|
280
291
|
}
|
|
281
292
|
__name(currentWorkflowCtx, "currentWorkflowCtx");
|
|
282
293
|
|
|
294
|
+
// src/ambient-step.ts
|
|
295
|
+
var import_node_async_hooks2 = require("async_hooks");
|
|
296
|
+
var STORAGE_KEY2 = Symbol.for("nestjs-durable:ambient-step-logger");
|
|
297
|
+
var globalRef2 = globalThis;
|
|
298
|
+
if (!globalRef2[STORAGE_KEY2]) {
|
|
299
|
+
globalRef2[STORAGE_KEY2] = new import_node_async_hooks2.AsyncLocalStorage();
|
|
300
|
+
}
|
|
301
|
+
var storage2 = globalRef2[STORAGE_KEY2];
|
|
302
|
+
function runInStepLogger(logger, fn) {
|
|
303
|
+
return storage2.run(logger, fn);
|
|
304
|
+
}
|
|
305
|
+
__name(runInStepLogger, "runInStepLogger");
|
|
306
|
+
function currentStep() {
|
|
307
|
+
return storage2.getStore();
|
|
308
|
+
}
|
|
309
|
+
__name(currentStep, "currentStep");
|
|
310
|
+
function log(level, message, data) {
|
|
311
|
+
currentStep()?.[level](message, data);
|
|
312
|
+
}
|
|
313
|
+
__name(log, "log");
|
|
314
|
+
function debug(message, data) {
|
|
315
|
+
currentStep()?.debug(message, data);
|
|
316
|
+
}
|
|
317
|
+
__name(debug, "debug");
|
|
318
|
+
function info(message, data) {
|
|
319
|
+
currentStep()?.info(message, data);
|
|
320
|
+
}
|
|
321
|
+
__name(info, "info");
|
|
322
|
+
function warn(message, data) {
|
|
323
|
+
currentStep()?.warn(message, data);
|
|
324
|
+
}
|
|
325
|
+
__name(warn, "warn");
|
|
326
|
+
function error(message, data) {
|
|
327
|
+
currentStep()?.error(message, data);
|
|
328
|
+
}
|
|
329
|
+
__name(error, "error");
|
|
330
|
+
function sub(name, status, message, data) {
|
|
331
|
+
currentStep()?.sub(name, status, message, data);
|
|
332
|
+
}
|
|
333
|
+
__name(sub, "sub");
|
|
334
|
+
function subEvent(e) {
|
|
335
|
+
currentStep()?.subEvent(e);
|
|
336
|
+
}
|
|
337
|
+
__name(subEvent, "subEvent");
|
|
338
|
+
var noopSubProcessHandle = {
|
|
339
|
+
phase: /* @__PURE__ */ __name(() => noopSubProcessHandle, "phase"),
|
|
340
|
+
skip: /* @__PURE__ */ __name(() => {
|
|
341
|
+
}, "skip"),
|
|
342
|
+
fail: /* @__PURE__ */ __name(() => {
|
|
343
|
+
}, "fail")
|
|
344
|
+
};
|
|
345
|
+
function subProcess(name, body, opts) {
|
|
346
|
+
const logger = currentStep();
|
|
347
|
+
if (!logger) return Promise.resolve(body(noopSubProcessHandle));
|
|
348
|
+
return logger.subProcess(name, body, opts);
|
|
349
|
+
}
|
|
350
|
+
__name(subProcess, "subProcess");
|
|
351
|
+
|
|
283
352
|
// src/control-flow-signal.ts
|
|
284
353
|
var CONTROL_FLOW_SIGNAL = Symbol.for("aviary:durable:control-flow");
|
|
285
|
-
function isWorkflowControlFlowSignal(
|
|
286
|
-
return typeof
|
|
354
|
+
function isWorkflowControlFlowSignal(error2) {
|
|
355
|
+
return typeof error2 === "object" && error2 !== null && error2[CONTROL_FLOW_SIGNAL] === true;
|
|
287
356
|
}
|
|
288
357
|
__name(isWorkflowControlFlowSignal, "isWorkflowControlFlowSignal");
|
|
289
358
|
|
|
@@ -420,11 +489,11 @@ __name(workflowName, "workflowName");
|
|
|
420
489
|
|
|
421
490
|
// src/durable-workflow.ts
|
|
422
491
|
var BINDINGS_KEY = Symbol.for("nestjs-durable:workflow-class-bindings");
|
|
423
|
-
var
|
|
424
|
-
if (!
|
|
425
|
-
|
|
492
|
+
var globalRef3 = globalThis;
|
|
493
|
+
if (!globalRef3[BINDINGS_KEY]) {
|
|
494
|
+
globalRef3[BINDINGS_KEY] = /* @__PURE__ */ new WeakMap();
|
|
426
495
|
}
|
|
427
|
-
var bindings =
|
|
496
|
+
var bindings = globalRef3[BINDINGS_KEY];
|
|
428
497
|
function bindWorkflowClass(ctor, client) {
|
|
429
498
|
bindings.set(ctor, client);
|
|
430
499
|
}
|
|
@@ -555,7 +624,7 @@ function createStepLogger(events, now) {
|
|
|
555
624
|
data
|
|
556
625
|
}
|
|
557
626
|
}), "push");
|
|
558
|
-
const
|
|
627
|
+
const subEvent2 = /* @__PURE__ */ __name((e) => events.push({
|
|
559
628
|
at: now(),
|
|
560
629
|
level: e.status === "failed" ? "error" : e.status === "skipped" ? "warn" : "info",
|
|
561
630
|
message: e.message ?? e.phase ?? e.name,
|
|
@@ -574,7 +643,7 @@ function createStepLogger(events, now) {
|
|
|
574
643
|
data: e.data
|
|
575
644
|
}
|
|
576
645
|
}), "subEvent");
|
|
577
|
-
const
|
|
646
|
+
const subProcess2 = /* @__PURE__ */ __name(async (name, body, opts) => {
|
|
578
647
|
const id = opts?.id ?? globalThis.crypto.randomUUID();
|
|
579
648
|
const group = opts?.group;
|
|
580
649
|
const start = now();
|
|
@@ -586,7 +655,7 @@ function createStepLogger(events, now) {
|
|
|
586
655
|
const emit = /* @__PURE__ */ __name((status, message, data) => {
|
|
587
656
|
if (terminal) return;
|
|
588
657
|
terminal = true;
|
|
589
|
-
|
|
658
|
+
subEvent2({
|
|
590
659
|
id,
|
|
591
660
|
name,
|
|
592
661
|
group,
|
|
@@ -597,7 +666,7 @@ function createStepLogger(events, now) {
|
|
|
597
666
|
}, "emit");
|
|
598
667
|
const handle = {
|
|
599
668
|
phase: /* @__PURE__ */ __name((phase, data) => {
|
|
600
|
-
if (!terminal)
|
|
669
|
+
if (!terminal) subEvent2({
|
|
601
670
|
id,
|
|
602
671
|
name,
|
|
603
672
|
group,
|
|
@@ -635,8 +704,8 @@ function createStepLogger(events, now) {
|
|
|
635
704
|
data
|
|
636
705
|
}
|
|
637
706
|
}), "sub"),
|
|
638
|
-
subEvent,
|
|
639
|
-
subProcess
|
|
707
|
+
subEvent: subEvent2,
|
|
708
|
+
subProcess: subProcess2
|
|
640
709
|
};
|
|
641
710
|
}
|
|
642
711
|
__name(createStepLogger, "createStepLogger");
|
|
@@ -670,7 +739,8 @@ async function runStepHandler(task, handler) {
|
|
|
670
739
|
events
|
|
671
740
|
} : result, "withEvents");
|
|
672
741
|
try {
|
|
673
|
-
const
|
|
742
|
+
const logger = createStepLogger(events, Date.now);
|
|
743
|
+
const output = await runInStepLogger(logger, () => handler(task.input, logger));
|
|
674
744
|
return withEvents({
|
|
675
745
|
...base,
|
|
676
746
|
status: "completed",
|
|
@@ -1720,7 +1790,10 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
|
|
|
1720
1790
|
seq: current,
|
|
1721
1791
|
attempt
|
|
1722
1792
|
};
|
|
1723
|
-
const body = /* @__PURE__ */ __name(() =>
|
|
1793
|
+
const body = /* @__PURE__ */ __name(() => {
|
|
1794
|
+
const logger = createStepLogger(events, host.clock);
|
|
1795
|
+
return runInStepLogger(logger, () => fn(logger));
|
|
1796
|
+
}, "body");
|
|
1724
1797
|
const output = host.interceptStep ? await host.interceptStep(invocation, body) : await body();
|
|
1725
1798
|
await host.completeStep({
|
|
1726
1799
|
runId,
|
|
@@ -3022,13 +3095,13 @@ var WorkflowEngine = class {
|
|
|
3022
3095
|
];
|
|
3023
3096
|
for (const run of inflight) {
|
|
3024
3097
|
if (run.createdAt.getTime() > deadline) continue;
|
|
3025
|
-
const
|
|
3098
|
+
const error2 = {
|
|
3026
3099
|
message: "execution timeout",
|
|
3027
3100
|
code: "execution_timeout"
|
|
3028
3101
|
};
|
|
3029
3102
|
await this.store.updateRun(run.id, {
|
|
3030
3103
|
status: "cancelled",
|
|
3031
|
-
error,
|
|
3104
|
+
error: error2,
|
|
3032
3105
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3033
3106
|
});
|
|
3034
3107
|
this.emit({
|
|
@@ -3036,7 +3109,7 @@ var WorkflowEngine = class {
|
|
|
3036
3109
|
runId: run.id,
|
|
3037
3110
|
workflow: run.workflow,
|
|
3038
3111
|
namespace: run.namespace,
|
|
3039
|
-
error
|
|
3112
|
+
error: error2
|
|
3040
3113
|
});
|
|
3041
3114
|
}
|
|
3042
3115
|
}
|
|
@@ -3051,6 +3124,22 @@ var WorkflowEngine = class {
|
|
|
3051
3124
|
for (const run of await this.store.listIncompleteRuns(this.namespace)) {
|
|
3052
3125
|
const acquired = await this.store.tryLockRun(run.id, this.instanceId, nowMs + this.leaseMs, nowMs);
|
|
3053
3126
|
if (!acquired) continue;
|
|
3127
|
+
if (run.status === "running") {
|
|
3128
|
+
const dispatched = await this.inFlightRemoteStep(run.id);
|
|
3129
|
+
if (dispatched) {
|
|
3130
|
+
await this.store.updateRun(run.id, {
|
|
3131
|
+
status: "suspended",
|
|
3132
|
+
wakeAt: this.reconcileWakeAt(dispatched.wakeAt ?? void 0),
|
|
3133
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
3134
|
+
});
|
|
3135
|
+
await this.store.releaseRunLock(run.id);
|
|
3136
|
+
results.push({
|
|
3137
|
+
runId: run.id,
|
|
3138
|
+
status: "suspended"
|
|
3139
|
+
});
|
|
3140
|
+
continue;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3054
3143
|
const settled = await this.countRecovery(run);
|
|
3055
3144
|
if (settled) {
|
|
3056
3145
|
results.push(settled);
|
|
@@ -3072,6 +3161,16 @@ var WorkflowEngine = class {
|
|
|
3072
3161
|
return results;
|
|
3073
3162
|
}
|
|
3074
3163
|
/**
|
|
3164
|
+
* The remote step this run dispatched and is still awaiting a result for, if any — the signature
|
|
3165
|
+
* that tells {@link recoverIncomplete} "this run's work is ON THE TRANSPORT, not in a crashed
|
|
3166
|
+
* process". A `pending` remote checkpoint is written BEFORE the dispatch and settled by the
|
|
3167
|
+
* worker's result, so its presence is the durable marker of an in-flight dispatched step.
|
|
3168
|
+
*/
|
|
3169
|
+
async inFlightRemoteStep(runId) {
|
|
3170
|
+
const checkpoints = await this.store.listCheckpoints(runId);
|
|
3171
|
+
return checkpoints.find((cp) => cp.kind === "remote" && cp.status === "pending");
|
|
3172
|
+
}
|
|
3173
|
+
/**
|
|
3075
3174
|
* Per-recovery bookkeeping (called once the lease is held): count the attempt, or — past
|
|
3076
3175
|
* `maxRecoveryAttempts` — move a poison pill to the `dead` dead-letter state. Returns a terminal
|
|
3077
3176
|
* result to skip the resume, or `undefined` to proceed.
|
|
@@ -3079,13 +3178,13 @@ var WorkflowEngine = class {
|
|
|
3079
3178
|
async countRecovery(run) {
|
|
3080
3179
|
const attempts = (run.recoveryAttempts ?? 0) + 1;
|
|
3081
3180
|
if (this.maxRecoveryAttempts != null && attempts > this.maxRecoveryAttempts) {
|
|
3082
|
-
const
|
|
3181
|
+
const error2 = {
|
|
3083
3182
|
message: `run exceeded maxRecoveryAttempts (${this.maxRecoveryAttempts}) \u2014 moved to dead-letter`,
|
|
3084
3183
|
code: "max_recovery_attempts"
|
|
3085
3184
|
};
|
|
3086
3185
|
await this.store.updateRun(run.id, {
|
|
3087
3186
|
status: "dead",
|
|
3088
|
-
error,
|
|
3187
|
+
error: error2,
|
|
3089
3188
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3090
3189
|
});
|
|
3091
3190
|
await this.store.releaseRunLock(run.id);
|
|
@@ -3094,18 +3193,18 @@ var WorkflowEngine = class {
|
|
|
3094
3193
|
runId: run.id,
|
|
3095
3194
|
workflow: run.workflow,
|
|
3096
3195
|
namespace: run.namespace,
|
|
3097
|
-
error
|
|
3196
|
+
error: error2
|
|
3098
3197
|
});
|
|
3099
3198
|
this.notifyDead({
|
|
3100
3199
|
...run,
|
|
3101
3200
|
status: "dead",
|
|
3102
|
-
error,
|
|
3201
|
+
error: error2,
|
|
3103
3202
|
recoveryAttempts: attempts
|
|
3104
3203
|
});
|
|
3105
3204
|
return {
|
|
3106
3205
|
runId: run.id,
|
|
3107
3206
|
status: "dead",
|
|
3108
|
-
error
|
|
3207
|
+
error: error2
|
|
3109
3208
|
};
|
|
3110
3209
|
}
|
|
3111
3210
|
await this.store.updateRun(run.id, {
|
|
@@ -3226,7 +3325,8 @@ var WorkflowEngine = class {
|
|
|
3226
3325
|
seen.add(runId);
|
|
3227
3326
|
const run = await this.store.getRun(runId);
|
|
3228
3327
|
if (!run) return null;
|
|
3229
|
-
|
|
3328
|
+
const resurrecting = run.status === "failed" || run.status === "dead";
|
|
3329
|
+
if (resurrecting) {
|
|
3230
3330
|
const isFailureCompletion = /* @__PURE__ */ __name((v) => typeof v === "object" && v !== null && v.ok === false, "isFailureCompletion");
|
|
3231
3331
|
for (const cp of await this.store.listCheckpoints(runId)) {
|
|
3232
3332
|
if (cp.status === "failed") {
|
|
@@ -3269,6 +3369,9 @@ var WorkflowEngine = class {
|
|
|
3269
3369
|
await this.store.updateRun(runId, {
|
|
3270
3370
|
status: "pending",
|
|
3271
3371
|
error: void 0,
|
|
3372
|
+
...resurrecting ? {
|
|
3373
|
+
recoveryAttempts: 0
|
|
3374
|
+
} : {},
|
|
3272
3375
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3273
3376
|
});
|
|
3274
3377
|
await this.runDispatcher.dispatch(runId);
|
|
@@ -3281,9 +3384,11 @@ var WorkflowEngine = class {
|
|
|
3281
3384
|
* Explicitly re-dispatch every remote step of `runId` stuck `pending` — the OPERATOR escape hatch for
|
|
3282
3385
|
* a run whose dispatched step job was LOST (worker crashed with no result, or a transport that dropped
|
|
3283
3386
|
* the job). No automatic recovery re-drives these: a reconcile re-drive re-suspends a still-pending
|
|
3284
|
-
* step by design (unless `remoteRedispatchMs` is set), `recoverIncomplete`
|
|
3285
|
-
*
|
|
3286
|
-
*
|
|
3387
|
+
* step by design (unless `remoteRedispatchMs` is set), `recoverIncomplete` explicitly SKIPS a run with
|
|
3388
|
+
* an in-flight `pending` remote step (it re-asserts the durably-suspended invariant instead of counting
|
|
3389
|
+
* a recovery attempt — see there), and `requeue` just replays back to the pending guard. This
|
|
3390
|
+
* re-enqueues the same `stepId` so the (idempotent) step re-runs and its result resumes the run.
|
|
3391
|
+
* Safe to call on a healthy run — it re-runs
|
|
3287
3392
|
* only in-flight `pending` remote steps, which are idempotent by the durable contract. Returns the
|
|
3288
3393
|
* run's current status (with the count re-dispatched), or null if the run is unknown.
|
|
3289
3394
|
*/
|
|
@@ -3575,10 +3680,10 @@ var WorkflowEngine = class {
|
|
|
3575
3680
|
});
|
|
3576
3681
|
}
|
|
3577
3682
|
/** Report that a `ctx.task` failed — the run resumes and throws a FatalError at the task. */
|
|
3578
|
-
async failTask(runId, name,
|
|
3683
|
+
async failTask(runId, name, error2) {
|
|
3579
3684
|
return this.signal(`task:${runId}:${name}`, {
|
|
3580
3685
|
ok: false,
|
|
3581
|
-
error
|
|
3686
|
+
error: error2
|
|
3582
3687
|
});
|
|
3583
3688
|
}
|
|
3584
3689
|
/**
|
|
@@ -3660,12 +3765,12 @@ var WorkflowEngine = class {
|
|
|
3660
3765
|
status: "cancelling"
|
|
3661
3766
|
};
|
|
3662
3767
|
}
|
|
3663
|
-
const
|
|
3768
|
+
const error2 = {
|
|
3664
3769
|
message: "cancelled"
|
|
3665
3770
|
};
|
|
3666
3771
|
await this.store.updateRun(runId, {
|
|
3667
3772
|
status: "cancelled",
|
|
3668
|
-
error,
|
|
3773
|
+
error: error2,
|
|
3669
3774
|
updatedAt: /* @__PURE__ */ new Date()
|
|
3670
3775
|
});
|
|
3671
3776
|
this.emit({
|
|
@@ -3673,7 +3778,7 @@ var WorkflowEngine = class {
|
|
|
3673
3778
|
runId,
|
|
3674
3779
|
workflow: run.workflow,
|
|
3675
3780
|
namespace: run.namespace,
|
|
3676
|
-
error
|
|
3781
|
+
error: error2
|
|
3677
3782
|
});
|
|
3678
3783
|
await this.cancelChildren(runId, opts);
|
|
3679
3784
|
this.notifyCancelled(runId);
|
|
@@ -3688,7 +3793,7 @@ var WorkflowEngine = class {
|
|
|
3688
3793
|
return {
|
|
3689
3794
|
runId,
|
|
3690
3795
|
status: "cancelled",
|
|
3691
|
-
error
|
|
3796
|
+
error: error2
|
|
3692
3797
|
};
|
|
3693
3798
|
}
|
|
3694
3799
|
/**
|
|
@@ -4083,12 +4188,12 @@ var WorkflowEngine = class {
|
|
|
4083
4188
|
}
|
|
4084
4189
|
async runRemoteExecution(run, registered) {
|
|
4085
4190
|
if (run.status === "cancelling") {
|
|
4086
|
-
const
|
|
4191
|
+
const error2 = {
|
|
4087
4192
|
message: "cancelled"
|
|
4088
4193
|
};
|
|
4089
4194
|
await this.store.updateRun(run.id, {
|
|
4090
4195
|
status: "cancelled",
|
|
4091
|
-
error,
|
|
4196
|
+
error: error2,
|
|
4092
4197
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4093
4198
|
});
|
|
4094
4199
|
this.emit({
|
|
@@ -4096,7 +4201,7 @@ var WorkflowEngine = class {
|
|
|
4096
4201
|
runId: run.id,
|
|
4097
4202
|
workflow: run.workflow,
|
|
4098
4203
|
namespace: run.namespace,
|
|
4099
|
-
error
|
|
4204
|
+
error: error2
|
|
4100
4205
|
});
|
|
4101
4206
|
this.notifyCancelled(run.id);
|
|
4102
4207
|
if (this.controlPlane) {
|
|
@@ -4110,7 +4215,7 @@ var WorkflowEngine = class {
|
|
|
4110
4215
|
return {
|
|
4111
4216
|
runId: run.id,
|
|
4112
4217
|
status: "cancelled",
|
|
4113
|
-
error
|
|
4218
|
+
error: error2
|
|
4114
4219
|
};
|
|
4115
4220
|
}
|
|
4116
4221
|
const remote = registered.remote;
|
|
@@ -4189,13 +4294,13 @@ var WorkflowEngine = class {
|
|
|
4189
4294
|
status: "running"
|
|
4190
4295
|
};
|
|
4191
4296
|
}
|
|
4192
|
-
const
|
|
4297
|
+
const error2 = {
|
|
4193
4298
|
message: err instanceof Error ? err.message : String(err),
|
|
4194
4299
|
stack: err instanceof Error ? err.stack : void 0
|
|
4195
4300
|
};
|
|
4196
4301
|
await this.store.updateRun(run.id, {
|
|
4197
4302
|
status: "failed",
|
|
4198
|
-
error,
|
|
4303
|
+
error: error2,
|
|
4199
4304
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4200
4305
|
});
|
|
4201
4306
|
this.emit({
|
|
@@ -4203,12 +4308,12 @@ var WorkflowEngine = class {
|
|
|
4203
4308
|
runId: run.id,
|
|
4204
4309
|
workflow: run.workflow,
|
|
4205
4310
|
namespace: run.namespace,
|
|
4206
|
-
error
|
|
4311
|
+
error: error2
|
|
4207
4312
|
});
|
|
4208
4313
|
return {
|
|
4209
4314
|
runId: run.id,
|
|
4210
4315
|
status: "failed",
|
|
4211
|
-
error
|
|
4316
|
+
error: error2
|
|
4212
4317
|
};
|
|
4213
4318
|
}
|
|
4214
4319
|
return this.applyDecision(run, decision);
|
|
@@ -4473,12 +4578,12 @@ var WorkflowEngine = class {
|
|
|
4473
4578
|
status: "cancelling"
|
|
4474
4579
|
};
|
|
4475
4580
|
this.cancelRequested.delete(run.id);
|
|
4476
|
-
const
|
|
4581
|
+
const error2 = {
|
|
4477
4582
|
message: "cancelled"
|
|
4478
4583
|
};
|
|
4479
4584
|
await this.store.updateRun(run.id, {
|
|
4480
4585
|
status: "cancelled",
|
|
4481
|
-
error,
|
|
4586
|
+
error: error2,
|
|
4482
4587
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4483
4588
|
});
|
|
4484
4589
|
this.emit({
|
|
@@ -4486,12 +4591,12 @@ var WorkflowEngine = class {
|
|
|
4486
4591
|
runId: run.id,
|
|
4487
4592
|
workflow: run.workflow,
|
|
4488
4593
|
namespace: run.namespace,
|
|
4489
|
-
error
|
|
4594
|
+
error: error2
|
|
4490
4595
|
});
|
|
4491
4596
|
return {
|
|
4492
4597
|
runId: run.id,
|
|
4493
4598
|
status: "cancelled",
|
|
4494
|
-
error
|
|
4599
|
+
error: error2
|
|
4495
4600
|
};
|
|
4496
4601
|
}
|
|
4497
4602
|
/** The run body, lease held + renewed by {@link execute}. */
|
|
@@ -4592,7 +4697,7 @@ var WorkflowEngine = class {
|
|
|
4592
4697
|
if (this.cancelRequested.has(run.id)) {
|
|
4593
4698
|
return this.compensateAndCancel(run, compensations, replay);
|
|
4594
4699
|
}
|
|
4595
|
-
const
|
|
4700
|
+
const error2 = {
|
|
4596
4701
|
message: err instanceof Error ? err.message : String(err),
|
|
4597
4702
|
stack: err instanceof Error ? err.stack : void 0
|
|
4598
4703
|
};
|
|
@@ -4603,7 +4708,7 @@ var WorkflowEngine = class {
|
|
|
4603
4708
|
});
|
|
4604
4709
|
return this.settleRun(run, {
|
|
4605
4710
|
kind: "failed",
|
|
4606
|
-
error
|
|
4711
|
+
error: error2
|
|
4607
4712
|
});
|
|
4608
4713
|
} finally {
|
|
4609
4714
|
await this.store.releaseRunLock(run.id);
|
|
@@ -4692,7 +4797,7 @@ var WorkflowEngine = class {
|
|
|
4692
4797
|
return;
|
|
4693
4798
|
} catch (err) {
|
|
4694
4799
|
if (attempt >= this.compensationRetries) {
|
|
4695
|
-
const
|
|
4800
|
+
const error2 = {
|
|
4696
4801
|
message: err instanceof Error ? err.message : String(err)
|
|
4697
4802
|
};
|
|
4698
4803
|
this.emit({
|
|
@@ -4701,7 +4806,7 @@ var WorkflowEngine = class {
|
|
|
4701
4806
|
workflow: run.workflow,
|
|
4702
4807
|
name,
|
|
4703
4808
|
kind: "local",
|
|
4704
|
-
error,
|
|
4809
|
+
error: error2,
|
|
4705
4810
|
durationMs: Date.now() - startedAt.getTime()
|
|
4706
4811
|
});
|
|
4707
4812
|
const cp = stepCheckpoint({
|
|
@@ -4711,7 +4816,7 @@ var WorkflowEngine = class {
|
|
|
4711
4816
|
kind: "local",
|
|
4712
4817
|
status: "failed",
|
|
4713
4818
|
attempts: attempt,
|
|
4714
|
-
error,
|
|
4819
|
+
error: error2,
|
|
4715
4820
|
enqueuedAt,
|
|
4716
4821
|
startedAt,
|
|
4717
4822
|
finishedAt: /* @__PURE__ */ new Date()
|
|
@@ -4967,14 +5072,14 @@ var WorkflowEngine = class {
|
|
|
4967
5072
|
error: current.error
|
|
4968
5073
|
};
|
|
4969
5074
|
}
|
|
4970
|
-
const
|
|
5075
|
+
const error2 = {
|
|
4971
5076
|
message: blocked.reason,
|
|
4972
5077
|
code: blocked.code,
|
|
4973
5078
|
retryable: true
|
|
4974
5079
|
};
|
|
4975
5080
|
await this.store.updateRun(run.id, {
|
|
4976
5081
|
status: "blocked",
|
|
4977
|
-
error,
|
|
5082
|
+
error: error2,
|
|
4978
5083
|
wakeAt: this.clock() + this.blockedPollMs,
|
|
4979
5084
|
updatedAt: /* @__PURE__ */ new Date()
|
|
4980
5085
|
});
|
|
@@ -4983,7 +5088,7 @@ var WorkflowEngine = class {
|
|
|
4983
5088
|
runId: run.id,
|
|
4984
5089
|
workflow: run.workflow,
|
|
4985
5090
|
namespace: run.namespace,
|
|
4986
|
-
error,
|
|
5091
|
+
error: error2,
|
|
4987
5092
|
requires: blocked.requires,
|
|
4988
5093
|
diagnostics: blocked.diagnostics
|
|
4989
5094
|
});
|
|
@@ -4991,7 +5096,7 @@ var WorkflowEngine = class {
|
|
|
4991
5096
|
return {
|
|
4992
5097
|
runId: run.id,
|
|
4993
5098
|
status: "blocked",
|
|
4994
|
-
error
|
|
5099
|
+
error: error2
|
|
4995
5100
|
};
|
|
4996
5101
|
}
|
|
4997
5102
|
/** Runs parked `blocked` whose recovery poll is due (`wakeAt <= nowMs`), namespace-scoped like
|
|
@@ -5376,6 +5481,13 @@ var TERMINAL_RUN_STATUSES = [
|
|
|
5376
5481
|
"dead"
|
|
5377
5482
|
];
|
|
5378
5483
|
|
|
5484
|
+
// src/run-gateway.ts
|
|
5485
|
+
var RunGateway = class {
|
|
5486
|
+
static {
|
|
5487
|
+
__name(this, "RunGateway");
|
|
5488
|
+
}
|
|
5489
|
+
};
|
|
5490
|
+
|
|
5379
5491
|
// src/codec-state-store.ts
|
|
5380
5492
|
var CodecStateStore = class {
|
|
5381
5493
|
static {
|
|
@@ -6182,6 +6294,7 @@ var InMemoryTransport = class {
|
|
|
6182
6294
|
RemoteStepTimeout,
|
|
6183
6295
|
RemoteWorkflowExecutor,
|
|
6184
6296
|
RemoteWorkflowTimeout,
|
|
6297
|
+
RunGateway,
|
|
6185
6298
|
STATE_STORE,
|
|
6186
6299
|
STATE_STORE_CANONICAL,
|
|
6187
6300
|
SignalTimeoutError,
|
|
@@ -6204,8 +6317,11 @@ var InMemoryTransport = class {
|
|
|
6204
6317
|
collectMetrics,
|
|
6205
6318
|
controlPlaneDescriptor,
|
|
6206
6319
|
createStepLogger,
|
|
6320
|
+
currentStep,
|
|
6207
6321
|
currentWorkflowCtx,
|
|
6322
|
+
debug,
|
|
6208
6323
|
descriptorHash,
|
|
6324
|
+
error,
|
|
6209
6325
|
eventMatchOf,
|
|
6210
6326
|
eventMatches,
|
|
6211
6327
|
eventNameOf,
|
|
@@ -6213,9 +6329,11 @@ var InMemoryTransport = class {
|
|
|
6213
6329
|
eventToken,
|
|
6214
6330
|
heartbeatStatus,
|
|
6215
6331
|
indexWaitersByRun,
|
|
6332
|
+
info,
|
|
6216
6333
|
isEventToken,
|
|
6217
6334
|
isLegacyDescriptor,
|
|
6218
6335
|
isWorkflowControlFlowSignal,
|
|
6336
|
+
log,
|
|
6219
6337
|
matchesAttributes,
|
|
6220
6338
|
missingCapabilities,
|
|
6221
6339
|
negotiate,
|
|
@@ -6228,6 +6346,7 @@ var InMemoryTransport = class {
|
|
|
6228
6346
|
requiredCapabilities,
|
|
6229
6347
|
resolveRouting,
|
|
6230
6348
|
resolveRunWaiting,
|
|
6349
|
+
runInStepLogger,
|
|
6231
6350
|
runInWorkflowCtx,
|
|
6232
6351
|
runSchedules,
|
|
6233
6352
|
runStepHandler,
|
|
@@ -6237,7 +6356,11 @@ var InMemoryTransport = class {
|
|
|
6237
6356
|
stepConfigOf,
|
|
6238
6357
|
stepId,
|
|
6239
6358
|
stepNameOf,
|
|
6359
|
+
sub,
|
|
6360
|
+
subEvent,
|
|
6361
|
+
subProcess,
|
|
6240
6362
|
tenantGroup,
|
|
6363
|
+
warn,
|
|
6241
6364
|
workflowName
|
|
6242
6365
|
});
|
|
6243
6366
|
//# sourceMappingURL=index.cjs.map
|