Repository navigation
fix(client): getResult() returns the close event that arrives when the timeout runs out - #846
Merged
xepozz merged 1 commit intoNov 4, 2026
Conversation
…e timeout runs out
RaphaelFakhri
requested review from
a team,
roxblnfk and
wolfy-j
as code owners
November 3, 2026 16:04
xepozz
approved these changes
Nov 4, 2026
Collaborator
|
Good finding, thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was changed
WorkflowStub::getCloseEvent()no longer throwsTimeoutExceptionbefore it reads the history response. The remaining timeout check moves to the loop condition, so it runs only when another long poll is needed (empty history or continue-as-new). A response that already holds the close event is returned.Why?
getCloseEvent()measures each long poll withtime()in whole seconds. When the remaining timeout reaches 0, it throwsTimeoutException('Unable to wait for workflow completion, deadline reached')and discards the response, even if the response contains the completed, failed, or canceled event.With
getResult(timeout: 1), a workflow that completes in about 100 ms fails whenever the call crosses a second boundary, which happens on roughly 1 call in 10. Larger timeouts fail the same way when the workflow completes in the last second before the deadline.Checklist
Closes [Bug] WorkflowStub::getResult() with a timeout throws TimeoutException even when the result has arrived #845
How was this tested:
Two unit tests in
tests/Unit/Internal/Client/WorkflowStubTestCase.php. Each mocksGetWorkflowExecutionHistoryso that it returns only after the second changes:testCloseEventReceivedAtDeadlineIsReturned: the response holds a completion event, andgetResult(timeout: 1)returns. Before the fix it throwsTimeoutException.testEmptyHistoryAtDeadlineThrowsTimeoutException: the response has no events, andgetResult(timeout: 1)still throwsTimeoutException.Before the fix: 3 tests, 1 error (
TimeoutException). After the fix: 3 tests pass.php-cs-fixerandpsalmreport no issues on the changed source file.Any docs updates needed?
No.