@dudousxd/nestjs-durable-core 0.104.0 → 0.105.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 +76 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +75 -55
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -246,6 +246,7 @@ __export(index_exports, {
|
|
|
246
246
|
resolveWireTenant: () => resolveWireTenant,
|
|
247
247
|
retentionKeeps: () => retentionKeeps,
|
|
248
248
|
retiredHandoffName: () => retiredHandoffName,
|
|
249
|
+
retryLocalStep: () => retryLocalStep,
|
|
249
250
|
routeFor: () => routeFor,
|
|
250
251
|
rowTenant: () => rowTenant,
|
|
251
252
|
runCompletedEvent: () => runCompletedEvent,
|
|
@@ -981,6 +982,27 @@ function backoffDelay(attempt, options) {
|
|
|
981
982
|
return options?.jitter ? Math.round(capped * (0.5 + Math.random() * 0.5)) : capped;
|
|
982
983
|
}
|
|
983
984
|
__name(backoffDelay, "backoffDelay");
|
|
985
|
+
async function retryLocalStep(options, attempt) {
|
|
986
|
+
const maxAttempts = Math.max(1, options?.retries ?? 1);
|
|
987
|
+
for (let n = 1; ; n += 1) {
|
|
988
|
+
try {
|
|
989
|
+
return {
|
|
990
|
+
ok: true,
|
|
991
|
+
value: await attempt(n),
|
|
992
|
+
attempts: n
|
|
993
|
+
};
|
|
994
|
+
} catch (error2) {
|
|
995
|
+
if (error2 instanceof FatalError || n >= maxAttempts) return {
|
|
996
|
+
ok: false,
|
|
997
|
+
error: error2,
|
|
998
|
+
attempts: n
|
|
999
|
+
};
|
|
1000
|
+
const wait = backoffDelay(n, options);
|
|
1001
|
+
if (wait > 0) await new Promise((resolve) => setTimeout(resolve, wait));
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
__name(retryLocalStep, "retryLocalStep");
|
|
984
1006
|
|
|
985
1007
|
// src/bounded-runner.ts
|
|
986
1008
|
var BoundedRunner = class {
|
|
@@ -6210,7 +6232,6 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
|
|
|
6210
6232
|
});
|
|
6211
6233
|
return existing.output;
|
|
6212
6234
|
}
|
|
6213
|
-
const maxAttempts = Math.max(1, options?.retries ?? 1);
|
|
6214
6235
|
const startedAt = /* @__PURE__ */ new Date();
|
|
6215
6236
|
await host.startStep({
|
|
6216
6237
|
runId,
|
|
@@ -6221,60 +6242,59 @@ function createWorkflowCtx(host, runId, compensations, workflow = "", searchAttr
|
|
|
6221
6242
|
enqueuedAt: startedAt,
|
|
6222
6243
|
startedAt
|
|
6223
6244
|
});
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
seq: current,
|
|
6260
|
-
name,
|
|
6261
|
-
kind: "local",
|
|
6262
|
-
error: {
|
|
6263
|
-
message: err instanceof Error ? err.message : String(err),
|
|
6264
|
-
stack: err instanceof Error ? err.stack : void 0,
|
|
6265
|
-
...codeAndDetails(err)
|
|
6266
|
-
},
|
|
6267
|
-
events,
|
|
6268
|
-
attempts: attempt,
|
|
6269
|
-
enqueuedAt: startedAt,
|
|
6270
|
-
startedAt
|
|
6271
|
-
});
|
|
6272
|
-
throw err;
|
|
6273
|
-
}
|
|
6274
|
-
const wait = backoffDelay(attempt, options);
|
|
6275
|
-
if (wait > 0) await new Promise((resolve) => setTimeout(resolve, wait));
|
|
6276
|
-
}
|
|
6245
|
+
let events = [];
|
|
6246
|
+
const outcome = await retryLocalStep(options, async (attempt) => {
|
|
6247
|
+
const attemptEvents = [];
|
|
6248
|
+
events = attemptEvents;
|
|
6249
|
+
const invocation = {
|
|
6250
|
+
runId,
|
|
6251
|
+
workflow,
|
|
6252
|
+
stepName: name,
|
|
6253
|
+
seq: current,
|
|
6254
|
+
attempt
|
|
6255
|
+
};
|
|
6256
|
+
const body = /* @__PURE__ */ __name(() => {
|
|
6257
|
+
const logger = createStepLogger(attemptEvents, host.clock);
|
|
6258
|
+
return runInStepScope(scopeOwner, name, () => runInStepLogger(logger, () => fn(logger)));
|
|
6259
|
+
}, "body");
|
|
6260
|
+
const output = host.interceptStep ? await host.interceptStep(invocation, body) : await body();
|
|
6261
|
+
await host.completeStep({
|
|
6262
|
+
runId,
|
|
6263
|
+
seq: current,
|
|
6264
|
+
name,
|
|
6265
|
+
kind: "local",
|
|
6266
|
+
output,
|
|
6267
|
+
events: attemptEvents,
|
|
6268
|
+
attempts: attempt,
|
|
6269
|
+
enqueuedAt: startedAt,
|
|
6270
|
+
startedAt
|
|
6271
|
+
});
|
|
6272
|
+
return output;
|
|
6273
|
+
});
|
|
6274
|
+
if (outcome.ok) {
|
|
6275
|
+
if (options?.compensate) compensations.push({
|
|
6276
|
+
name,
|
|
6277
|
+
fn: options.compensate
|
|
6278
|
+
});
|
|
6279
|
+
return outcome.value;
|
|
6277
6280
|
}
|
|
6281
|
+
const err = outcome.error;
|
|
6282
|
+
await host.failStep({
|
|
6283
|
+
runId,
|
|
6284
|
+
seq: current,
|
|
6285
|
+
name,
|
|
6286
|
+
kind: "local",
|
|
6287
|
+
error: {
|
|
6288
|
+
message: err instanceof Error ? err.message : String(err),
|
|
6289
|
+
stack: err instanceof Error ? err.stack : void 0,
|
|
6290
|
+
...codeAndDetails(err)
|
|
6291
|
+
},
|
|
6292
|
+
events,
|
|
6293
|
+
attempts: outcome.attempts,
|
|
6294
|
+
enqueuedAt: startedAt,
|
|
6295
|
+
startedAt
|
|
6296
|
+
});
|
|
6297
|
+
throw err;
|
|
6278
6298
|
}, "localStep");
|
|
6279
6299
|
const transaction = /* @__PURE__ */ __name(async (name, fn) => {
|
|
6280
6300
|
if (!store.transaction) {
|
|
@@ -14403,7 +14423,7 @@ ${run.workflowVersion}`;
|
|
|
14403
14423
|
output: cmd.output,
|
|
14404
14424
|
error: cmd.error,
|
|
14405
14425
|
events: cmd.events,
|
|
14406
|
-
attempts: 1,
|
|
14426
|
+
attempts: cmd.attempts ?? 1,
|
|
14407
14427
|
enqueuedAt: startedAt,
|
|
14408
14428
|
startedAt,
|
|
14409
14429
|
finishedAt,
|
|
@@ -19434,6 +19454,7 @@ __name(settleResultsWithPlainCalls, "settleResultsWithPlainCalls");
|
|
|
19434
19454
|
resolveWireTenant,
|
|
19435
19455
|
retentionKeeps,
|
|
19436
19456
|
retiredHandoffName,
|
|
19457
|
+
retryLocalStep,
|
|
19437
19458
|
routeFor,
|
|
19438
19459
|
rowTenant,
|
|
19439
19460
|
runCompletedEvent,
|