question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Test server seems to not enable time skipping in this specific scenario

See original GitHub issue

Expected Behavior

W2 7 day timer should be unblocked immediately.

Actual Behavior

Timer is not unblocked.

Steps to Reproduce the Problem

(I have not run this myself and verified, this is pseudo code I got from a user on slack)

async function W1() {
    await A1();
    ...
}

async function A1() {
  const ids = runDBQuery();

  const { workflowClient } = getContext();

  await Promise.all(
    ids.map((id) =>
      workflowClient.signalWithStart(W2, {
        taskQueue: "default",
        workflowId: `W2-${id}`,
        args: [
          {
            ...
          },
        ],
        signal: S1,
        signalArgs: [{ ... }],
      })
    ),
  );
}

async function W2() {
    await sleep("7 days");
    await A2();
    ...
}

async function A2() {
    // produce side effect
}

describe("test T1", () => {
    it("alls A2", async () => {
        const testActivities = {
          ...activities,
          A2: jest.fn(),
        };


        const testEnv = await TestWorkflowEnvironment.createTimeSkipping();
        const worker = await Worker.create({
          connection: testEnv.nativeConnection,
          workflowsPath: require.resolve("./allWorkflows"),
          interceptors: appendDefaultInterceptors(
            {
              activityInbound: [
                (ctx) =>
                  new CustomActivityInboundInterceptor(ctx, {
                    workflowClient: testEnv.client.workflow,
                  }),
              ],
            },
            console
          ),
          activities: testActivities,
          taskQueue: "default",
        });

        await worker.runUntil(() => 
          testEnv.client.workflow.execute(
            W1,
            {
              workflowId: randomUUID(),
              taskQueue: "default",
              args: [
                {
                  ...
                },
              ],
            }
          )
        )

        const handle = testEnv.client.workflow.getHandle(`W2-id1`);
        await handle.result();

        expect(testActivities.A2).toHaveBeenCalled();
    })
})

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Spikhalskiycommented, Dec 10, 2022

@maxgurewitz Thanks for the clarification, it makes more sense if they wait only for a start. I will try to repro it and get back to you, I don’t expect it to be a Test Server bug, but it may be a TS SDK bug. How many workflows does A1 start in your test? One or several?

0reactions
bergundycommented, Dec 10, 2022

Looks like the worker in this example is shut down before the second workflow gets a chance to complete.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to programmatically skip a test in mocha? - Stack Overflow
The question asks about programmatically skipping tests, so adding ".skip" or ".only" is not helpful. Then it explicitly says you can't do what...
Read more >
Dealing With Synchronization Issues in Tests | Detox
We are waiting too much - The test will appear to hang and fail with timeout. This happens because Detox thinks an asynchronous...
Read more >
Authoring Tasks - Gradle User Manual
Task has actions, but the task tells Gradle it did not change its outputs. ... configureEach { enabled = false } tasks.register('test') {...
Read more >
Configuration File - WebdriverIO
The configuration file contains all necessary information to run your test suite. It's a NodeJS module that exports a JSON.
Read more >
Component testing scenarios - Angular
A server takes time to respond and the response certainly won't be available immediately as in the previous two tests. Your tests will...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found