Improve error handling in external signals #330
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.
This change is a follow up to #134 that improves error handling when using external signals to send a signal from one workflow to another.
The core change is that when sending a signal fails, the value returned by calling
.get
or passed as the argument to a callback on the future returned byworkflow.signal_external_workflow
now is an error indicating the error type rather than the fixed string of'StandardError'
. Previously, although the cause enum was passed to the dispatcher in the state manager, it was not propagated to callbacks on the future, only the fixed string.Technically, this is a breaking change. It's unlikely existing usage of this would rely on a meaningless string constant. Still, usage of type checking of callback methods via Sorbet could be impacted when a different type is now passed (see Sorbet docs) even if the value is not used.
There's a few other supporting changes here:
WaitForExternalSignalWorkflow
sample has been updated. Its test has been updated for the most common failure mode that the target workflow does not exist. I've also added some default execution timeouts to these tests to reduce lingering workflow runs when the tests fail.StateManager
andWorkflow::Context
unit specs have been added to cover this new failure mode as well as success cases previously not covered. These can be run with,bundle exec rspec spec/unit/lib/temporal/workflow/context_spec.rb:265
bundle exec rspec spec/unit/lib/temporal/workflow/state_manager_spec.rb:437