Skip to content

feat: allow passing AwaitOptions to Workflow::awaitWithTimeout() - #805

Open
xepozz wants to merge 3 commits into
temporalio:masterfrom
xepozz:feature/await-with-timeout-options
Open

xepozz wants to merge 3 commits into
temporalio:masterfrom
xepozz:feature/await-with-timeout-options

Conversation

@xepozz

@xepozz xepozz commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

What was changed

AwaitOptions is now public (Temporal\Workflow) and accepted as the first argument of Workflow::awaitWithTimeout(), so the await timer can get TimerOptions (summary).

Why?

Timer options were always null, so concurrent awaits were indistinguishable in UI.

Closes #803

Checklist

  1. Closes [Feature Request] Allow passing AwaitOptions to Workflow::awaitWithTimeout() #803
  2. How was this tested: unit + functional/acceptance tests asserting summary and interval in workflow history.
  3. Any docs updates needed? No.

`awaitWithTimeout()` already created `AwaitOptions` internally, but always
with `null` timer options, so the underlying timer could not be configured.

Move `AwaitOptions` to the public `Temporal\Workflow` namespace with an
immutable API (`new()`, `withInterval()`, `withTimerOptions()`) and accept it
as the first argument of `Workflow::awaitWithTimeout()`, renamed to
`$intervalOrOptions`. This exposes `TimerOptions` (e.g. `summary`) for the
timer created by the await, making concurrent awaits distinguishable in
UI/CLI.

The class was marked as internal and experimental, so it is moved as is,
without an alias for the old name. Method signatures of
`Workflow::awaitWithTimeout()` and `WorkflowContextInterface::awaitWithTimeout()`
are untouched.

Closes temporalio#803
Unit tests check that the summary reaches the `NewTimer` command and that the
public DTO is immutable.

Functional tests run real workflows against the test server and assert against
the workflow history that the timer created by `awaitWithTimeout()` carries the
summary and the interval from `AwaitOptions`, that concurrent awaits produce
their own summaries, that the timer is started and fired (not cancelled), and
that a plain timeout value or `AwaitOptions` without `TimerOptions` produce a
timer without user metadata.
@xepozz
xepozz requested review from a team, roxblnfk and wolfy-j as code owners September 11, 2026 07:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d541b1055

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Workflow.php
* @return PromiseInterface<bool>
*/
public static function awaitWithTimeout($interval, callable|Mutex|PromiseInterface ...$conditions): PromiseInterface
public static function awaitWithTimeout($intervalOrOptions, callable|Mutex|PromiseInterface ...$conditions): PromiseInterface

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve the existing interval parameter name

Existing PHP 8 callers may use the public API as Workflow::awaitWithTimeout(interval: 5, conditions: fn() => true). Renaming $interval to $intervalOrOptions makes that call fail with an ArgumentCountError because the required first argument is no longer recognized. Keep the parameter named $interval while allowing it to contain either a timeout value or AwaitOptions to avoid this backward-compatibility break.

Useful? React with 👍 / 👎.

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.

[Feature Request] Allow passing AwaitOptions to Workflow::awaitWithTimeout()

1 participant