From cbce046b1555da107d5d0788791cbf2f04f50533 Mon Sep 17 00:00:00 2001 From: Duncan Mackenzie Date: Mon, 5 Oct 2026 11:57:46 -0700 Subject: [PATCH] Fix TypeScript samples that use APIs missing from @temporalio 1.24.0 - fixed-count-retries: import RetryState from @temporalio/common; the workflow package doesn't re-export it. - fixed-wall-time-retries: TimeoutFailure has timeoutType, not type; import TimeoutType from @temporalio/common. - testing-suite: fix the heatbeat import typo. - temporal-client: client.getHandle() was the old WorkflowClient API; use client.workflow.getHandle(). Drop the redundant second handle declaration in the start sample. - workflow-streams: the TypeScript SDK has no executeActivity; call the Activity through proxyActivities. --- docs/design-patterns/fixed-count-retries.mdx | 3 ++- docs/design-patterns/fixed-wall-time-retries.mdx | 3 ++- .../typescript/best-practices/testing-suite.mdx | 2 +- docs/develop/typescript/client/temporal-client.mdx | 5 ++--- docs/develop/typescript/workflows/workflow-streams.mdx | 10 ++++++---- 5 files changed, 13 insertions(+), 10 deletions(-) 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