-
Notifications
You must be signed in to change notification settings - Fork 272
Fix canceling external workflows that are children in testsuite #1968
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
base: master
Are you sure you want to change the base?
Conversation
|
Do you know why the feature tests are failing for your PR? |
|
Seems like it was a transient issue, features tests are passing now after merging with master |
| env.postCallback(func() { | ||
| env.onChildWorkflowCanceledListener(env.workflowInfo) | ||
| }, false) | ||
| sd.dispatcher.NewCoroutine(sd.rootCtx, "cancel-self", true, func(ctx Context) { |
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.
isn't running the postCallback enough?
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.
Added a comment explaining why this would be needed, not sure it's worth a larger refactor, lmk if you think otherwise
// The way testWorkflowEnvironment is setup today, we close the child workflow dispatcher before calling
// the workflowCancelHandler. A larger refactor would be needed to handle this similar to non-test code.
// Maybe worth doing when https://github.com/temporalio/go-sdk/issues/50 is tackled.
| // the workflowCancelHandler. A larger refactor would be needed to handle this similar to non-test code. | ||
| // Maybe worth doing when https://github.com/temporalio/go-sdk/issues/50 is tackled. | ||
| if sd, ok := env.workflowDef.(*syncWorkflowDefinition); ok && env.isChildWorkflow() { | ||
| sd.dispatcher.NewCoroutine(sd.rootCtx, "cancel-self", true, func(ctx Context) { |
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.
Will this run immediately? Any compatibly concern with running this in a coroutine now and changing the sequence with onChildWorkflowCanceledListener?
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.
good callout, the onChildWorkflowCanceledListener logic should only run during the coroutine we spawn
What was changed
Dispatch a new coroutine with workflow context when canceling external workflow in workflow testsuite
Why?
Fix testsuite specific error
Checklist
Closes Getting a strange error when writing tests which does not occur in real temporal deployment #1961
How was this tested:
Added test
Note
When canceling the current (child) workflow via external cancel, run the cancel handler in a new dispatcher coroutine to avoid illegal access errors; add a test covering this path.
RequestCancelExternalWorkflowtargeting the current workflow, wrap cancel logic incancelFuncand, if a child workflow with*syncWorkflowDefinition, dispatch it via a new coroutine on the workflow dispatcher; otherwise call directly. Ensures child-cancel flows run within workflow context.SleepHour,SleepThenCancelworkflows andTestRequestCancelExternalWorkflowInSelectorto validate canceling an external child workflow (timer cancel path) succeeds without "illegal access" errors.Written by Cursor Bugbot for commit 1edd76a. This will update automatically on new commits. Configure here.