-
Notifications
You must be signed in to change notification settings - Fork 107
[Fix] Non-started activity cancellation #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| require 'workflows/long_workflow' | ||
|
|
||
| describe 'Activity cancellation' do | ||
| let(:workflow_id) { SecureRandom.uuid } | ||
|
|
||
| it 'cancels a running activity' do | ||
| run_id = Temporal.start_workflow(LongWorkflow, options: { workflow_id: workflow_id }) | ||
|
|
||
| # Signal workflow after starting, allowing it to schedule the first activity | ||
| sleep 0.5 | ||
| Temporal.signal_workflow(LongWorkflow, :CANCEL, workflow_id, run_id) | ||
|
|
||
| result = Temporal.await_workflow_result( | ||
| LongWorkflow, | ||
| workflow_id: workflow_id, | ||
| run_id: run_id, | ||
| ) | ||
|
|
||
| expect(result).to be_a(LongRunningActivity::Canceled) | ||
| expect(result.message).to eq('cancel activity request received') | ||
| end | ||
|
|
||
| it 'cancels a non-started activity' do | ||
| # Workflow is started with a signal which will cancel an activity before it has started | ||
| run_id = Temporal.start_workflow(LongWorkflow, options: { | ||
| workflow_id: workflow_id, | ||
| signal_name: :CANCEL | ||
| }) | ||
|
|
||
| result = Temporal.await_workflow_result( | ||
| LongWorkflow, | ||
| workflow_id: workflow_id, | ||
| run_id: run_id, | ||
| ) | ||
|
|
||
| expect(result).to be_a(Temporal::ActivityCanceled) | ||
| expect(result.message).to eq('ACTIVITY_ID_NOT_STARTED') | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,6 @@ def execute(cycles = 10, interval = 1) | |
| future.cancel | ||
| end | ||
|
|
||
| future.wait | ||
| future.get | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,9 @@ class TimeoutError < ClientError; end | |
| # with the intent to propagate to a workflow | ||
| class ActivityException < ClientError; end | ||
|
|
||
| # Represents cancellation of a non-started activity | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since cancels can also happen at a heartbeat, should we unify this case with that case? It's not ideal that people would have to deal with both depending on the timing of when the cancellation comes in.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's nothing preventing other to re-use the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I forgot that in this SDK, heartbeat cancel doesn't throw, it returns a boolean. |
||
| class ActivityCanceled < ActivityException; end | ||
|
|
||
| class ActivityNotRegistered < ClientError; end | ||
| class WorkflowNotRegistered < ClientError; end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is always failing for me, locally