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

I’d like to confirm my understand of how Temporal handles uncaught Exceptions thrown outside of Activities. I have written my current understanding below, and I have a few specific questions about it.

  1. Are these cases accurate?
  2. Am I missing any other expected/standard cases?
  3. Is there standard Temporal terminology for these 3 cases, for example “replay” vs “retry”?
  4. Is case 3 the same thing that happens when a worker crashes? If not, what’s the difference?

How I think it works:

  • Case 1: thrown Exception extends Temporal Failure

Expected Result: Workflow fails and closes with no retries.

  • 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. Q: In the event of a full retry, is the pervious EventHistory retained anywhere?

  • 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.

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.