@dudousxd/nestjs-durable-testing 0.26.0 → 0.26.1

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.js CHANGED
@@ -6132,6 +6132,43 @@ function runStateStoreContract(name, makeStore) {
6132
6132
  expect3(resumed.output).toBe(15);
6133
6133
  expect3(aRuns).toBe(1);
6134
6134
  });
6135
+ t("retries a failed run whose lease is still held, once the holder releases it or it expires", async () => {
6136
+ const engine = new WorkflowEngine3({
6137
+ store
6138
+ });
6139
+ const failing = /* @__PURE__ */ new Set([
6140
+ "held",
6141
+ "expiring"
6142
+ ]);
6143
+ engine.register("wf", "1", async (ctx) => {
6144
+ const a = await ctx.localStep("a", async () => 10);
6145
+ return ctx.localStep("b", async () => {
6146
+ if (failing.delete(ctx.runId)) throw new Error("boom");
6147
+ return a + 5;
6148
+ });
6149
+ });
6150
+ for (const id of [
6151
+ "held",
6152
+ "expiring"
6153
+ ]) {
6154
+ await engine.start("wf", {}, id);
6155
+ expect3((await engine.waitForRun(id)).status).toBe("failed");
6156
+ }
6157
+ expect3(await store.tryLockRun("held", "holder", Date.now() + 6e4, Date.now())).toBe(true);
6158
+ const held = engine.resume("held");
6159
+ setTimeout(() => void store.releaseRunLock("held", "holder"), 150);
6160
+ expect3(await held).toMatchObject({
6161
+ status: "completed",
6162
+ output: 15
6163
+ });
6164
+ expect3(await store.tryLockRun("expiring", "gone", Date.now() + 200, Date.now())).toBe(true);
6165
+ expect3(await engine.resume("expiring")).toMatchObject({
6166
+ status: "completed",
6167
+ output: 15
6168
+ });
6169
+ expect3((await store.getRun("expiring"))?.status).toBe("completed");
6170
+ await engine.drain();
6171
+ });
6135
6172
  t("starts the version the caller pinned, and refuses one that is not registered", async () => {
6136
6173
  const engine = new WorkflowEngine3({
6137
6174
  store