Skip to content

[Bug] Workflows can be constructed in which update handlers do not, but should, execute #1474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dandavison opened this issue Jul 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@dandavison
Copy link
Contributor

dandavison commented Jul 24, 2024

If the workflow below is started, and then a signal and an update are sent in the 2nd Workflow task, the workflow exits without the update handler ever being executed. See @bergundy's original comment #1459 (review)

export async function workflow(): Promise<string> {
  var numFoos = 0;

  wf.setHandler(fooSignal, () => {
    numFoos++;
  });

  wf.setHandler(fooUpdate, () => {
    numFoos++;
  });

  await wf.condition(() => numFoos > 0);
  return `foos: ${numFoos}`;
}

The fix will be to group update activation jobs together with signals here:

const [patches, nonPatches] = partition(activation.jobs, ({ notifyHasPatch }) => notifyHasPatch != null);
const [signals, nonSignals] = partition(nonPatches, ({ signalWorkflow }) => signalWorkflow != null);
const [queries, rest] = partition(nonSignals, ({ queryWorkflow }) => queryWorkflow != null);
let batchIndex = 0;

Fixing this will be backwards incompatible w.r.t. replay of existing workflows, so will need to use an SDK flag.

We did not update that code when we implemented update because core orders the activation jobs and we were planning to eliminate this typescript code, but this decision overlooked the fact that update and signal activation jobs need to be placed into the same batch in order for them all to be executed before giving the chance for an awaitable such as the workflow.condition() above to be unblocked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant