diff --git a/docs/design-patterns/fixed-count-retries.mdx b/docs/design-patterns/fixed-count-retries.mdx index 058c4a90ce..99140acba6 100644 --- a/docs/design-patterns/fixed-count-retries.mdx +++ b/docs/design-patterns/fixed-count-retries.mdx @@ -190,6 +190,7 @@ public class PaymentWorkflowImpl implements PaymentWorkflow { ```typescript // workflows.ts +import { RetryState } from '@temporalio/common'; import * as wf from '@temporalio/workflow'; import type * as activities from './activities'; @@ -202,7 +203,7 @@ export async function paymentWorkflow(orderId: string): Promise { try { return await chargePaymentApi(orderId); } catch (err) { - if (err instanceof wf.ActivityFailure && err.retryState === wf.RetryState.MAXIMUM_ATTEMPTS_REACHED) { + if (err instanceof wf.ActivityFailure && err.retryState === RetryState.MAXIMUM_ATTEMPTS_REACHED) { // All retries exhausted — handle the failure here. // Options: alert on-call, trigger a compensation activity, or escalate to a human. wf.log.error('Payment failed: all 3 attempts exhausted', { orderId }); diff --git a/docs/design-patterns/fixed-wall-time-retries.mdx b/docs/design-patterns/fixed-wall-time-retries.mdx index 3166752a29..e6751dfaf4 100644 --- a/docs/design-patterns/fixed-wall-time-retries.mdx +++ b/docs/design-patterns/fixed-wall-time-retries.mdx @@ -200,6 +200,7 @@ public class PaymentAuthWorkflowImpl implements PaymentAuthWorkflow { ```typescript // workflows.ts +import { TimeoutType } from '@temporalio/common'; import * as wf from '@temporalio/workflow'; import type * as activities from './activities'; @@ -219,7 +220,7 @@ export async function paymentAuthWorkflow(transactionId: string): Promise { ```typescript -import { condition, defineSignal, executeActivity, setHandler } from '@temporalio/workflow'; +import { condition, defineSignal, proxyActivities, setHandler } from '@temporalio/workflow'; import { WorkflowStream } from '@temporalio/workflow-streams/workflow'; import type * as activities from './activities'; +const { streamCompletion } = proxyActivities({ + startToCloseTimeout: '5 minutes', +}); + export const subscriberAcknowledgedTerminator = defineSignal('subscriberAcknowledgedTerminator'); export interface ChatInput { @@ -428,9 +432,7 @@ export async function chatWorkflow(input: ChatInput): Promise { subscriberDone = true; }); - const result = await executeActivity('streamCompletion', input.prompt, { - startToCloseTimeout: '5 minutes', - }); + const result = await streamCompletion(input.prompt); // Wait for the subscriber to ack the terminal `close` event. The timeout // is a fallback for when no subscriber is attached; with the ack, the