Skip to content
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

Don't run workflowCancelHandler in test harness #1296

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

Don't run workflowCancelHandler in test harness on completed workflows. If a workflow is completed nothing else in the workflow function should run.

closes #1287

@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner November 20, 2023 23:01
Comment on lines -878 to -883
var canceledErr *CanceledError
if errors.As(err, &canceledErr) && env.workflowCancelHandler != nil {
env.workflowCancelHandler()
}
Copy link
Member

@cretz cretz Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand this change? Is it just because As checks errors at every depth and if so, maybe we should change to just checking the exact error type instead of hierarchy? Can you confirm that there is no other internal way for a cancel to be sent to a test workflow than via TestWorkflowEnvironment.CancelWorkflow() (which appears to still invoke this callback)?

Copy link
Contributor Author

@Quinn-With-Two-Ns Quinn-With-Two-Ns Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is because canceling a workflow that has already returned is not valid. If the workflow function has already returned what valid effect can the cancel call have?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is also inconsistent with executing a workflow normally not in the test suite. Executing a workflow normally does not have this behavior so it is an inconsistency that leads to panics in the SDK

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I was originally concerned that there was a user-facing callback that could be registered to this, but I have manually confirmed there is not.

Don't run workflowCancelHandler in test harness on
completed workflows.
@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit 838121a into temporalio:master Dec 4, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error "getState: illegal access from outside of workflow context" after sdk update 1.22.1 -> 1.25.1
2 participants