@@ -1084,9 +1084,12 @@ func (a *activityExecutorWrapper) Execute(ctx context.Context, input []byte) ([]
10841084 activityInfo := GetActivityInfo (ctx )
10851085 dc := getDataConverterFromActivityCtx (ctx )
10861086 if a .env .onActivityStartedListener != nil {
1087+ waitCh := make (chan struct {})
10871088 a .env .postCallback (func () {
10881089 a .env .onActivityStartedListener (& activityInfo , ctx , newEncodedValues (input , dc ))
1090+ close (waitCh )
10891091 }, false )
1092+ <- waitCh // wait until listener returns
10901093 }
10911094
10921095 m := & mockWrapper {env : a .env , name : a .name , fn : a .fn , isWorkflow : false , dataConverter : dc }
@@ -1101,9 +1104,12 @@ func (a *activityExecutorWrapper) Execute(ctx context.Context, input []byte) ([]
11011104func (a * activityExecutorWrapper ) ExecuteWithActualArgs (ctx context.Context , inputArgs []interface {}) ([]byte , error ) {
11021105 activityInfo := GetActivityInfo (ctx )
11031106 if a .env .onLocalActivityStartedListener != nil {
1107+ waitCh := make (chan struct {})
11041108 a .env .postCallback (func () {
11051109 a .env .onLocalActivityStartedListener (& activityInfo , ctx , inputArgs )
1110+ close (waitCh )
11061111 }, false )
1112+ <- waitCh
11071113 }
11081114
11091115 m := & mockWrapper {env : a .env , name : a .name , fn : a .fn , isWorkflow : false }
@@ -1118,9 +1124,7 @@ func (a *activityExecutorWrapper) ExecuteWithActualArgs(ctx context.Context, inp
11181124func (w * workflowExecutorWrapper ) Execute (ctx Context , input []byte ) (result []byte , err error ) {
11191125 env := w .env
11201126 if env .isChildWorkflow () && env .onChildWorkflowStartedListener != nil {
1121- env .postCallback (func () {
1122- env .onChildWorkflowStartedListener (GetWorkflowInfo (ctx ), ctx , newEncodedValues (input , w .env .GetDataConverter ()))
1123- }, false )
1127+ env .onChildWorkflowStartedListener (GetWorkflowInfo (ctx ), ctx , newEncodedValues (input , w .env .GetDataConverter ()))
11241128 }
11251129
11261130 if ! env .isChildWorkflow () {
0 commit comments