Use a read Context when checking for callbacks to close (#8746)

When processing callbacks in mutable state use a read only context to
validate there are callbacks to process, if there are get the writeable
context to process the callbacks.

## What changed?
Use a read context to check for callbacks

## Why?
Removes a write of the root workflow component persisted / replicated
upon close.

## How did you test it?
- [ ] built
- [ ] run locally and tested manually
- [X] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)

## Potential risks
NA, not rolled out for users yet
This commit is contained in:
Sean Kane
2025-12-03 18:50:07 +00:00
committed by GitHub
parent d791a04d1b
commit c3252bd7f4
@@ -6421,6 +6421,17 @@ func (ms *MutableStateImpl) processCloseCallbacksHsm() error {
// processCloseCallbacksChasm triggers "WorkflowClosed" callbacks using the CHASM implementation.
func (ms *MutableStateImpl) processCloseCallbacksChasm() error {
wf, _, err := ms.ChasmWorkflowComponentReadOnly(context.Background())
if err != nil {
return err
}
// Return early if there are no chasm callbacks to process.
if len(wf.Callbacks) == 0 {
return nil
}
// If there are callbacks to process, create a writable workflow component.
wf, ctx, err := ms.ChasmWorkflowComponent(context.Background())
if err != nil {
return err