Conversation
`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.
There was a problem hiding this comment.
💡 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".
| * @return PromiseInterface<bool> | ||
| */ | ||
| public static function awaitWithTimeout($interval, callable|Mutex|PromiseInterface ...$conditions): PromiseInterface | ||
| public static function awaitWithTimeout($intervalOrOptions, callable|Mutex|PromiseInterface ...$conditions): PromiseInterface |
There was a problem hiding this comment.
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 👍 / 👎.
What was changed
AwaitOptionsis now public (Temporal\Workflow) and accepted as the first argument ofWorkflow::awaitWithTimeout(), so the await timer can getTimerOptions(summary).Why?
Timer options were always
null, so concurrent awaits were indistinguishable in UI.Closes #803
Checklist
AwaitOptionstoWorkflow::awaitWithTimeout()#803