# Child workflow still keeps retrying when its activity caught non retryable error

**URL:** <https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711>\
**Category:** Community Support\
**Tags:** go-sdk\
**Created:** [October 17, 2024, 6:23pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711 "2024-10-17T18:23:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xinyi](https://avatars.discourse-cdn.com/v4/letter/x/7ea924/32.png) [@Xinyi](https://community.temporal.io/u/Xinyi)\
**Post date:** [October 17, 2024, 6:23pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/1 "2024-10-17T18:23:28Z")

</div>

I have a child workflow running an activity. Inside the activity, it throws non-retryable application error. The child workflow fails only for that execution run. Its retry state is still Retry State In Progress. And it spins up a new execution run immediately.

Is this expected? How to stop the child workflow from retrying in such case?

---

<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:** [October 17, 2024, 6:31pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/2 "2024-10-17T18:31:12Z")

</div>

Did you set retry options for the child?

---

<div class="post-metadata">

**Author:** ![Xinyi](https://avatars.discourse-cdn.com/v4/letter/x/7ea924/32.png) [@Xinyi](https://community.temporal.io/u/Xinyi)\
**Post date:** [October 17, 2024, 6:38pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/3 "2024-10-17T18:38:41Z")

</div>

Yes. I set the RetryPolicy as below and WorkflowExecutionTimeout to 30 min.

&temporal.RetryPolicy{  
InitialInterval: 1 \* time.Second,  
MaximumInterval: 1 \* time.Second,  
MaximumAttempts: 0,  
},

---

<div class="post-metadata">

**Author:** ![Xinyi](https://avatars.discourse-cdn.com/v4/letter/x/7ea924/32.png) [@Xinyi](https://community.temporal.io/u/Xinyi)\
**Post date:** [October 17, 2024, 6:54pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/4 "2024-10-17T18:54:22Z")

</div>

This is that failed child workflow result. The activity is RETRY\_STATE\_NON\_RETRYABLE\_FAILURE, while the child workflow is still RETRY\_STATE\_IN\_PROGRESS

 ![Screenshot 2024-10-17 at 11.51.04 AM](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/7/70b10de9027150014f46ace76f899705a7711835.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:** [October 17, 2024, 7:05pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/5 "2024-10-17T19:05:20Z")

</div>

The nonretryable failure is thrown from the activity, and the activity is not retried. The workflow receives it wrapped in an ActivityFailure, which is retryable. If you want to the workflow to retry you should throw an NonRetryable failure from the workflow directly.

---

<div class="post-metadata">

**Author:** ![Xinyi](https://avatars.discourse-cdn.com/v4/letter/x/7ea924/32.png) [@Xinyi](https://community.temporal.io/u/Xinyi)\
**Post date:** [October 17, 2024, 11:10pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/6 "2024-10-17T23:10:11Z")

</div>

@maxim The child workflow is still retrying with this code.

```auto
func (w Worker) MyChildWorkflow(
  ...
) (
  ...
) {
	err := workflow.ExecuteActivity(ctx, MyActivity, ...).Get(ctx, nil)
	if err != nil {
		var applicationErr *temporal.ApplicationError
			if errors.As(err, &applicationErr) {
				if applicationErr.NonRetryable() {
					err = temporal.NewNonRetryableApplicationError("activity failed", "NonRetryableFailure", err)
				}
			}
		return
	}
}

```

---

<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:** [October 18, 2024, 12:25am UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/7 "2024-10-18T00:25:09Z")

</div>

Your code worked for me. This is the error that caused the child workflow to fail without retrying.

```auto
{
  "message": "activity failed",
  "source": "GoSDK",
  "cause": {
    "message": "activity error",
    "source": "GoSDK",
    "cause": {
      "message": "simulated activity error",
      "source": "GoSDK",
      "applicationFailureInfo": {
        "type": "Simulated",
        "nonRetryable": true
      }
    },
    "activityFailureInfo": {
      "scheduledEventId": "8",
      "startedEventId": "9",
      "identity": "93992@Maxims-MacBook-Pro.local@",
      "activityType": {
        "name": "ChildActivity"
      },
      "activityId": "8",
      "retryState": "RETRY_STATE_NON_RETRYABLE_FAILURE"
    }
  },
  "applicationFailureInfo": {
    "type": "NonRetryableFailure",
    "nonRetryable": true
  }
}

```

---

<div class="post-metadata">

**Author:** ![Xinyi](https://avatars.discourse-cdn.com/v4/letter/x/7ea924/32.png) [@Xinyi](https://community.temporal.io/u/Xinyi)\
**Post date:** [October 18, 2024, 1:10am UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/8 "2024-10-18T01:10:49Z")

</div>

@maxim Thanks for checking! I think I kind of realized the issue. In my code, it didn’t even get to this `err = temporal.NewNonRetryableApplicationError("activity failed", "NonRetryableFailure", err)` line of code. I’m getting below from the child workflow result in temporal UI. So looks like `errors.As(err, &applicationErr)` returns false?

```auto
{
  "message": "activity error",
  "source": "GoSDK",
  "cause": {
    "message": "xxx",
    "source": "GoSDK",
    "cause": {
      "message": "xxx",
      "source": "GoSDK",
      "applicationFailureInfo": {}
    },
    "applicationFailureInfo": {
      "type": "InvalidParameter",
      "nonRetryable": true
    }
  },
  "activityFailureInfo": {
    "scheduledEventId": "11",
    "startedEventId": "12",
    "identity": "xxx",
    "activityType": {
      "name": "xxx"
    },
    "activityId": "11",
    "retryState": "RETRY_STATE_NON_RETRYABLE_FAILURE"
  }
}

```

---

<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:** [October 18, 2024, 1:56am UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/9 "2024-10-18T01:56:05Z")

</div>

This is my code: [Comparing temporalio:main...mfateev:error-handling · temporalio/samples-go · GitHub](https://github.com/temporalio/samples-go/compare/main...mfateev:temporal-go-samples:error-handling)

---

<div class="post-metadata">

**Author:** ![Xinyi](https://avatars.discourse-cdn.com/v4/letter/x/7ea924/32.png) [@Xinyi](https://community.temporal.io/u/Xinyi)\
**Post date:** [October 18, 2024, 6:02pm UTC](https://community.temporal.io/t/child-workflow-still-keeps-retrying-when-its-activity-caught-non-retryable-error/14711/10 "2024-10-18T18:02:18Z")

</div>

Issue solved finally. That code actually works for me as well. Thanks for addressing this
