Skip to content

Instantly share code, notes, and snippets.

@DCCoder90
Created December 4, 2025 04:39
Show Gist options
  • Select an option

  • Save DCCoder90/68c8981fbcbc44a7d25e6ccf2a601688 to your computer and use it in GitHub Desktop.

Select an option

Save DCCoder90/68c8981fbcbc44a7d25e6ccf2a601688 to your computer and use it in GitHub Desktop.
A go snippet showing how to handle a hard timeout with Temporal.io
func Workflow(ctx workflow.Context, details PaymentDetails) error {
ao := workflow.ActivityOptions{
StartToCloseTimeout: 10 * time.Second // This is the X seconds limit, currently set to 10 seconds
}
ctx = workflow.WithActivityOptions(ctx, ao)
var result string
err := workflow.ExecuteActivity(ctx, ProcessPaymentActivity, details).Get(ctx, &result)
if err != nil {
// If we exhausted retries or hit a non-retryable error
var timeoutErr *temporal.ApplicationError // or TimeoutError depending on SDK version
if errors.As(err, &timeoutErr) {
// Handle the timeout logic here, such as cleaning up
return err
}
return err
}
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment