temporalio / temporal

Temporal service
https://docs.temporal.io
MIT License
10.3k stars 754 forks source link

Handle NextRetryDelay option in workflow failures #5946

Closed gow closed 1 week ago

gow commented 2 weeks ago

What changed?

Workflows can now return an application error with NextRetryDelay option to customize when the workflow will be retried again.

  return temporal.NewApplicationError(
    "some retryable error",
    "SomeType",
    temporal.ApplicationErrorOptions{NextRetryDelay: 2 * time.Minute},
  )

Why?

Currently Activity tasks can customize the next retry time. This is bringing the same feature to workflow tasks as well.

How did you test it?

Added unit tests. Also added a test to assert next retry delay customization in activities.

Potential risks

Documentation

Is hotfix candidate?

No

gow commented 1 week ago

Is this only for handling the failure of the first attempt of the workflow task?

No. It's meant to handle failure with NextRetryDelay in any attempt of the workflow task. What gave you the impression that it's applied only to the first attempt?

gow commented 1 week ago

Is this only for handling the failure of the first attempt of the workflow task?

No. It's meant to handle failure with NextRetryDelay in any attempt of the workflow task. What gave you the impression that it's applied only to the first attempt?

Synced offline. The confusion was me calling it "workflow task" which is a different construct than the workflow code (or simply workflow). This change works as intended for the workflows where it can return an application error to customize its next retry delay.