What are the different ways Temporal handles exceptions thrown in Workflows?

By default, workflows by default don’t have retry options and are not retried when failed or timed out.

  • Case 1 : thrown Exception extends Temporal Failure

Expected Result : Workflow fails and closes with no retries.

Workflow fails and is retried (by executing from the beginning) only if retry options are specified.

  • Case 2 : thrown Exception does not extend TemporalFailure and is specified in WorkflowImplementationOptions.setFailWorkflowExceptionTypes

Expected Result : Workflow retries from scratch, ignoring EventHistory and re-executing any activities as well as the special Workflow.random*() methods.

The same as Case 1. Workflow fails and is retried (by executing from the beginning) only if retry options are specified.

Q : In the event of a full retry, is the pervious EventHistory retained anywhere?

The workflow retry is modeled as a new workflow run. So it gets a new runId. The previous run data including its event history is still available up to the retention period.

  • Case 3 : thrown Exception does not extend TemporalFailure and is not specified in WorkflowImplementationOptions.setFailWorkflowExceptionTypes (like an NPE)

Expected Result : Workflow replays indefinitely or until hitting a timeout, using the Event History, waiting for a fix.

Correct.