Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/design-patterns/fixed-count-retries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -202,7 +203,7 @@ export async function paymentWorkflow(orderId: string): Promise<string> {
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 });
Expand Down
3 changes: 2 additions & 1 deletion docs/design-patterns/fixed-wall-time-retries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -219,7 +220,7 @@ export async function paymentAuthWorkflow(transactionId: string): Promise<string
} catch (err) {
if (err instanceof wf.ActivityFailure) {
const cause = err.cause;
if (cause instanceof wf.TimeoutFailure && cause.type === wf.TimeoutType.SCHEDULE_TO_CLOSE) {
if (cause instanceof wf.TimeoutFailure && cause.timeoutType === TimeoutType.SCHEDULE_TO_CLOSE) {
wf.log.error('Authorization failed — 2-minute SLA breached', { transactionId });
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/develop/typescript/best-practices/testing-suite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ If an Activity is supposed to react to a Cancellation, you can test whether it r
[`MockActivityEnvironment`](https://typescript.temporal.io/api/classes/testing.MockActivityEnvironment) exposes a [`.cancel()`](https://typescript.temporal.io/api/classes/testing.MockActivityEnvironment#cancel) method that cancels the Activity Context.

```ts
import { CancelledFailure, heatbeat, sleep } from '@temporalio/activity';
import { CancelledFailure, heartbeat, sleep } from '@temporalio/activity';
import { MockActivityEnvironment } from '@temporalio/testing';
import assert from 'assert';

Expand Down
5 changes: 2 additions & 3 deletions docs/develop/typescript/client/temporal-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,6 @@ const handle = await client.workflow.start(example, {
taskQueue: 'your-task-queue',
args: ['argument01', 'argument02', 'argument03'], // this is typechecked against workflowFn's args
});
const handle = client.getHandle(workflowId);
const result = await handle.result();
```

Expand Down Expand Up @@ -811,7 +810,7 @@ If you started a Workflow with `client.workflow.start()`, you can choose to wait
`handle.result()`.

```typescript
const handle = client.getHandle(workflowId);
const handle = client.workflow.getHandle(workflowId);
const result = await handle.result();
```

Expand All @@ -822,7 +821,7 @@ If you call `result()` on a Workflow that prematurely ended for some reason, it
reason. For that reason, it is recommended to catch that error.

```typescript
const handle = client.getHandle(workflowId);
const handle = client.workflow.getHandle(workflowId);
try {
const result = await handle.result();
} catch (err) {
Expand Down
10 changes: 6 additions & 4 deletions docs/develop/typescript/workflows/workflow-streams.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,14 @@ export async function streamCompletion(prompt: string): Promise<string> {
<TabItem value="workflow" label="workflows.ts">

```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<typeof activities>({
startToCloseTimeout: '5 minutes',
});

export const subscriberAcknowledgedTerminator = defineSignal('subscriberAcknowledgedTerminator');

export interface ChatInput {
Expand All @@ -428,9 +432,7 @@ export async function chatWorkflow(input: ChatInput): Promise<string> {
subscriberDone = true;
});

const result = await executeActivity<typeof activities.streamCompletion>('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
Expand Down
Loading