Skip to content

Add promise-based workflow await - #3055

Open
baekgyu-kim wants to merge 1 commit into
temporalio:mainfrom
baekgyu-kim:1937
Open

baekgyu-kim wants to merge 1 commit into
temporalio:mainfrom
baekgyu-kim:1937

Conversation

@baekgyu-kim

Copy link
Copy Markdown
Contributor

What was changed

  • Added Async.await(Duration, Supplier<Boolean>), a non-blocking, promise-based version of Workflow.await.
  • Runs the existing Workflow.await on a separate workflow thread. The promise completes with true when the condition is met, false on timeout, or exceptionally on cancellation or a predicate exception.
  • Added tests for completion, timeout, cancellation, predicate exceptions, non-blocking behavior, and composition with an activity promise.

Why?

Workflow.await blocks the current workflow thread, so its result cannot be combined with other promises. This API allows workflows to use an await condition with Promise.allOf, for example when waiting for both a signal and an activity.

Checklist

  1. Closes Support a promise-based await #1937

  2. How was this tested:

    ./gradlew :temporal-sdk:test --offline \
      --tests io.temporal.workflow.AsyncAwaitTest \
      --tests io.temporal.workflow.AwaitTest \
      --tests io.temporal.workflow.cancellationTests.WorkflowAwaitCancelTimerOnConditionTest
  3. Any docs updates needed?

    No. The new API is documented with Javadocs.

* @return promise that contains whether the condition was satisfied before the timeout.
*/
public static Promise<Boolean> await(Duration timeout, Supplier<Boolean> unblockCondition) {
return AsyncInternal.await(timeout, unblockCondition);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add a overload that take no duration to be consisiten with Workflow.await

@baekgyu-kim baekgyu-kim Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Quinn-With-Two-Ns, thanks for taking a look at this issue.

I added a no-timeout overload to match Workflow.await, along with documentation and tests.
Please take a look when you have a chance. Thanks!

@Quinn-With-Two-Ns Quinn-With-Two-Ns self-assigned this Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support a promise-based await

2 participants