Replicate official SDK to fetch results from Temporal #305
+47
−17
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.
While running long workflows that require synchronous results,
await_workflow_result
throws the following exception:pointing to line https://github.com/coinbase/temporal-ruby/blob/master/lib/temporal/client.rb#L251
Reason:
When trying to fetch workflow execution history with
event_type: :close
, Temporal sends empty events payload after next event (not necessarily close event)Calling
.first.type
fails on empty event.Fix:
Follow what official SDK does in Go and TS. Create a loop and try and fetch close event till it can find one
TS Example:
https://github.com/temporalio/sdk-typescript/blob/913e67e6381c421c3ed02ee24518adfa1243c84c/packages/client/src/workflow-client.ts#L630
Go Example:
https://github.com/temporalio/sdk-go/blob/626785769094562b39662d6076304c807b596ed9/internal/internal_workflow_client.go#L433-L436
This PR tries to replicate the same behavior