@dudousxd/nestjs-durable-testing 0.22.1 → 0.22.2

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
@@ -853,7 +853,7 @@ function runStateStoreContract(name, makeStore) {
853
853
  supportsTagFilter = ctx.supportsTagFilter ?? true;
854
854
  skipReason = void 0;
855
855
  } catch (err) {
856
- if (isUnavailable(err)) {
856
+ if (isUnavailable(err) && !process.env.DURABLE_TEST_REQUIRE_BACKENDS) {
857
857
  skipReason = err.message;
858
858
  if (!loggedSkip) {
859
859
  console.warn(`[state-store-contract] SKIPPING "${name}": ${skipReason}`);
@@ -4393,7 +4393,10 @@ function instances(store, transports, clock) {
4393
4393
  });
4394
4394
  }
4395
4395
  __name(instances, "instances");
4396
- function registerFan(all, fanSize, ran, settle2) {
4396
+ function registerFan(all, fanSize, ran, settle2, spreadWithinMs) {
4397
+ const executors = /* @__PURE__ */ __name(() => new Set([
4398
+ ...ran.values()
4399
+ ].map(([first]) => first)), "executors");
4397
4400
  for (const { name, engine } of all) {
4398
4401
  engine.register("child", "1", async (ctx, input) => {
4399
4402
  const { i } = input;
@@ -4402,6 +4405,9 @@ function registerFan(all, fanSize, ran, settle2) {
4402
4405
  ...ran.get(i) ?? [],
4403
4406
  name
4404
4407
  ]);
4408
+ if (spreadWithinMs !== void 0) {
4409
+ await until(() => executors().size >= all.length, spreadWithinMs).catch(() => void 0);
4410
+ }
4405
4411
  await pause(15);
4406
4412
  return i * 2;
4407
4413
  });
@@ -4583,7 +4589,7 @@ function runRunDispatchContract(name, makeHarness, options = {}) {
4583
4589
  const store = new InMemoryStateStore4();
4584
4590
  const all = instances(store, pair);
4585
4591
  const ran = /* @__PURE__ */ new Map();
4586
- registerFan(all, fanSize, ran, settle2);
4592
+ registerFan(all, fanSize, ran, settle2, timeoutMs / 2);
4587
4593
  try {
4588
4594
  for (const { engine } of all) engine.consumeRuns();
4589
4595
  await all[0]?.engine.start("parent", {}, "p");
@@ -4625,8 +4631,13 @@ function runRunDispatchContract(name, makeHarness, options = {}) {
4625
4631
  expect4(turns).toBe(0);
4626
4632
  a.failing.on = false;
4627
4633
  await engine.runPending();
4628
- await until(async () => (await store.getRun("lost"))?.status === "completed", timeoutMs);
4629
- expect4((await store.getRun("kept"))?.status).toBe("completed");
4634
+ await until(async () => {
4635
+ const [lost, kept] = await Promise.all([
4636
+ store.getRun("lost"),
4637
+ store.getRun("kept")
4638
+ ]);
4639
+ return lost?.status === "completed" && kept?.status === "completed";
4640
+ }, timeoutMs);
4630
4641
  a.failing.on = true;
4631
4642
  await engine.start("wf", {}, "down");
4632
4643
  await pause(50);