BackgroundJob.ContinueWith - JobContinuationOptions.OnAnyFinishedState - Not Firing On Parent Failure

Continuations using option JobContinuationOptions.OnAnyFinishedState do not consider Failed to be a finished state. Only Deleted and Succeeded are considered finished states (by continuations).

If you manually delete the failed parent job (via the dashboard) you should see you continuation job being processed.

You can configure the parent job to automatically be deleted once the retry count is exceeded by using the AutomaticRetryAttribute:

[AutomaticRetry(OnAttemptsExceeded = AttemptsExceededAction.Delete)]

I also found this behaviour confusing, and only worked out what was going on by reading the source code. it would be great if JobContinuationOptions could be extended to include an option for triggering continuation on parent job failure without having to delete the parent job.

2 Likes