Non-Determinism and Sleep: Is it ok to calculate sleep duration at runtime?

Brad_Johnson
Fri, 12 Jan 2024 22:04:36 +0000
Community Support

Hello folks. I’ve been searching for answers for a few days, but can’t find the specific answer I need.

I have a workflow activity that is set up something like this:

  ... do some things ...
  duration := calculateDurationBetweenNowAndNextMonday(workflow.Now())
  workflow.Sleep(ctx, duration)
  ... run the next activity in the workflow ...

I’m concerned that this might cause my workflow to throw NonDeterministicErrors because the duration of the sleep will be different each time the workflow runs.

Does “Sleep” even affect the “determinism” of the workflow. Or is it excepted from this concern?

4 posts - 3 participants