temporalio / temporalio/features

[Feature Request] Workfow sleep/await with 0 duration

Open
#145 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
32
Forks
28
Avg merge
1d 9h
Merged PRs (30d)
7

Description

Example:

 Workflow.await(Duration.ofSeconds(n), () -> condition);
 activities.doSomething(...);

Workflow.await / sleep produces different sequence of events if n<=0 and when n>0 (basically if n>0 will have TimerStarted event from command in history, if n<=0 TimerStarted event is not in history)
Similar for Workflow.sleep

This can cause non-deterministic issues during replay, if user calculates n in workflow code (even if they do not use system time, but some initial wf inputs so code itself is deterministic).

Feature request is for SDKS not to cause non-deterministic failure here and replay the workflow task but to log it and dont fail.
Another option could be to fail workflow task with like "duration cannot be 0" or similar message but first option imo would be preferred if possible

Workarounds are currently for the "n" calculation to be done inside side effect or local activity/activity so n is not re-calculated on replay each time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the SDK implementations of Workflow.await and Workflow.sleep, using the zero- versus nonzero-duration example to compare replay behavior. No specific files or tests are named; inspect the repository's compatibility-testing setup first. Done means zero-duration calculations no longer cause nondeterministic replay failure, with the chosen logging or explicit-error behavior covered by tests.

Written by the indexing model from the issue text.

Assessment

Domain
distributed-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.