# How to skip a short-live err activity without change workflow or activity code, and no worker restart

**URL:** <https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852>\
**Category:** Community Support\
**Tags:** go-sdk\
**Created:** [August 31, 2022, 3:13am UTC](https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852 "2022-08-31T03:13:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackban](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@jackban](https://community.temporal.io/u/jackban)\
**Post date:** [August 31, 2022, 3:13am UTC](https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852/1 "2022-08-31T03:13:56Z")

</div>

the scene is that there is a short-live activity , it may failed due to outer service quality, the outer service might down for hours, in the time the activity won’t be success,. but there a way to finish the job manually which workaround the outer service.

so is there a way to skip an err activity? besides the way has to comply with

- non-blocking
- no code change of the running workflow/activity, no worker restart

* * *

what i have tried .

1. _tctl activity complete to skip_. it doesn’t work for the scene cause the activity failed immediately, u can’t complete a failed activity
2. _interceptor and signal_ . i thought the best place is “activityInboundInterceptor ExecuteActivity”, but can’t find a non-blocking way to pass a signal to it

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 31, 2022, 3:19am UTC](https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852/2 "2022-08-31T03:19:21Z")

</div>

1. Here is the [issue](https://github.com/temporalio/temporal/issues/987) to get this fixed.

2. Activity interceptor wraps the activity execution, not its invocation by the workflow. Use [WorkflowOutboundInterceptor](https://github.com/temporalio/sdk-go/blob/7151653bdadc6d2645d3543bfc3ad5dfd3bd4551/internal/interceptor.go#L175) which runs in the workflow context instead.

---

<div class="post-metadata">

**Author:** ![jackban](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@jackban](https://community.temporal.io/u/jackban)\
**Post date:** [August 31, 2022, 3:35am UTC](https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852/3 "2022-08-31T03:35:48Z")

</div>

tks for answering

1. seems the issue won’t be close recently .

2. workflowOutboundInterceptor can’t handle the scene i thought, “workflowOutboundInterceptor ExecuteActivity” return a Future, couldn’t handler activity here, any suggestions?

3. is there any other ways to skip a short-live activity when it’s failed ? has to change the workflow code and restart woker?

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 31, 2022, 3:57am UTC](https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852/4 "2022-08-31T03:57:06Z")

</div>

1. I don’t understand your comment. The outbound interceptor intercepts an activity invocation from the workflow. See this [example](https://github.com/temporalio/sdk-go/blob/7151653bdadc6d2645d3543bfc3ad5dfd3bd4551/interceptor/tracing_interceptor.go#L353). You can listen to signal in the interceptor, then cancel activity on signal.

---

<div class="post-metadata">

**Author:** ![jackban](https://avatars.discourse-cdn.com/v4/letter/j/c4cdca/32.png) [@jackban](https://community.temporal.io/u/jackban)\
**Post date:** [August 31, 2022, 5:35am UTC](https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852/5 "2022-08-31T05:35:19Z")

</div>

tks for your patience

maybe there is some misunderstanding , let me show u the code

with the codes below. when i send signal “SkipErrActivityForOneTime=true” , the whole workflow was canceled, but my expect is cancel/skip the activity only. what is wrong?

* * *

the workflow

```auto
func GreetingWorkflow(ctx workflow.Context, name string) (string, error) {
	options := workflow.ActivityOptions{
		...
	}
	ctx = workflow.WithActivityOptions(ctx, options)

	var result string
	// failed immediately
	err := workflow.ExecuteActivity(ctx, activities.ComposeGreeting, activities.GreetingParam{"jack"}).Get(ctx, &result)
	if err != nil {
		return "", err
	}

	// other activities ...

	return "", nil
}

```

* * *

the activity

```auto
// failed immediately
func ComposeGreeting(param GreetingParam) (string, error) {
	return "", errors.New("bad error greeting")
}

```

* * *

the interceptor

save param pointer to ctx

```auto
func (w *workflowInboundInterceptor) ExecuteWorkflow(
	ctx workflow.Context,
	in *interceptor.ExecuteWorkflowInput,
) (interface{}, error) {
	// save the pointer to ctx
	cancelFuncP := cancelFuncStruct{cancelFunc: nil, cancelActivity: nil}
	ctx = workflow.WithValue(ctx, "pauseCancelFunc", &cancelFuncP)
	flowControl := workflows.FlowControl{}
	ctx = workflow.WithValue(ctx, "flowControl", &flowControl)
	
	// fetch signal aync
	workflow.Go(ctx, flowSignalHandler)

	return w.Next.ExecuteWorkflow(ctx, in)
}

```

expose the cancelHandler to ctx

```auto
func (w *workflowOutboundInterceptor) ExecuteActivity(ctx workflow.Context, activityType string, args ...interface{}) workflow.Future {

	childCtx, cancelHandler := workflow.WithCancel(ctx)
	cancelFuncP := ctx.Value("pauseCancelFunc").(*cancelFuncStruct)
	cancelFuncP.cancelActivity = cancelHandler

	wFuture := w.Next.ExecuteActivity(childCtx, activityType, args...)

	return wFuture
}

```

flowSignalHandler to handle singal

```auto
func flowSignalHandler(ctx workflow.Context) {
	flowControl := ctx.Value("flowControl").(*workflows.FlowControl)
	signalChan := workflow.GetSignalChannel(ctx, "flowControl")
	// keep handler signal in the loop
	for {
		signalChan.Receive(ctx, &flowControl)
		if flowControl.SkipErrActivityForOneTime == true {
			// try to cancel activity execution
			cancelFuncP := ctx.Value("pauseCancelFunc").(*cancelFuncStruct)
			cancelFuncP.cancelActivity()
		}
	}
}

```

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/f/f4047fab28aeaec18cf2dc29139ee32f1d088ce3.png)

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [August 31, 2022, 3:53pm UTC](https://community.temporal.io/t/how-to-skip-a-short-live-err-activity-without-change-workflow-or-activity-code-and-no-worker-restart/5852/6 "2022-08-31T15:53:40Z")

</div>

I guess that you canceled the activity, which caused it to return a cancellation error. The workflow handled that error by returning it from the workflow function. This was interpreted as workflow cancellation.

I think you want to retry the activity in the case of a cancellation request.
