From d9c6f2d3863eb7cd5bfe8833c7d1311e3153c1d5 Mon Sep 17 00:00:00 2001 From: Duncan Mackenzie Date: Mon, 5 Oct 2026 11:30:25 -0700 Subject: [PATCH 1/2] Fix nonexistent Connection.create() in TypeScript Task Queue sample Connection in @temporalio/client has only connect() and lazy(); create() has never existed. Also fix the Worker sample comment naming the wrong Task Queue and the Set a Workflow Id text that said client.workflow.start() starts a Client. Fixes #5200 --- docs/develop/typescript/client/temporal-client.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/develop/typescript/client/temporal-client.mdx b/docs/develop/typescript/client/temporal-client.mdx index 1bc4133f2e..e9f996833d 100644 --- a/docs/develop/typescript/client/temporal-client.mdx +++ b/docs/develop/typescript/client/temporal-client.mdx @@ -721,7 +721,7 @@ async function run() { // If you need to configure server connection parameters, see docs: // /typescript/security#encryption-in-transit-with-mtls - // Step 2: Start accepting tasks on the `tutorial` queue + // Step 2: Start accepting tasks on the `hello-world` queue await worker.run(); } @@ -739,7 +739,7 @@ When scheduling a Workflow, you must specify `taskQueue`. ```ts import { Client, Connection } from '@temporalio/client'; // This is the code that is used to start a Workflow. -const connection = await Connection.create(); +const connection = await Connection.connect(); const client = new Client({ connection }); const result = await client.workflow.execute(yourWorkflow, { // required @@ -769,7 +769,7 @@ Although it is not required, we recommend providing your own [Workflow Id](/workflow-execution/workflowid-runid#workflow-id) that maps to a business process or business entity identifier, such as an order identifier or customer identifier. -Connect to a Client with `client.workflow.start()` and any arguments. Then specify your `taskQueue` and set your +Call `client.workflow.start()` with your Workflow and any arguments. Then specify your `taskQueue` and set your `workflowId` to a meaningful business identifier. ```typescript @@ -780,7 +780,7 @@ const handle = await client.workflow.start(example, { }); ``` -This starts a new Client with the given Workflow Id, Task Queue name, and an argument. +This starts a Workflow Execution with the given Workflow ID, Task Queue name, and arguments. ## Get Workflow results {/* #get-workflow-results */} From 2bfddd289b4b548f5341cb6f4c05b403da324fec Mon Sep 17 00:00:00 2001 From: Duncan Mackenzie Date: Mon, 5 Oct 2026 11:36:36 -0700 Subject: [PATCH 2/2] Source TypeScript Task Queue samples from samples-typescript via Snipsync Replace the hand-written Worker and client samples in Set a Workflow's Task Queue with the typescript-worker-create and typescript-start-workflow snippets, so they're compiled in samples-typescript CI. Drop the duplicate Worker.create() fragment, which repeated the Worker sample above it. --- .../typescript/client/temporal-client.mdx | 55 ++++++++----------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/docs/develop/typescript/client/temporal-client.mdx b/docs/develop/typescript/client/temporal-client.mdx index e9f996833d..e7ea7b1d56 100644 --- a/docs/develop/typescript/client/temporal-client.mdx +++ b/docs/develop/typescript/client/temporal-client.mdx @@ -703,61 +703,52 @@ The Worker needs three main things: `require.resolve('./workflows')`. Workflows are bundled with their dependencies. - If you prefer to handle the bundling yourself, pass a prebuilt bundle to `workflowBundle`. + +[snippets/src/worker.ts](https://github.com/temporalio/samples-typescript/blob/main/snippets/src/worker.ts) ```ts import { Worker } from '@temporalio/worker'; import * as activities from './activities'; async function run() { - // Step 1: Register Workflows and Activities with the Worker and connect to - // the Temporal server. const worker = await Worker.create({ workflowsPath: require.resolve('./workflows'), + taskQueue: 'snippets', activities, - taskQueue: 'hello-world', }); - // Worker connects to localhost by default and uses console.error for logging. - // Customize the Worker by passing more options to create(): - // https://typescript.temporal.io/api/classes/worker.Worker - // If you need to configure server connection parameters, see docs: - // /typescript/security#encryption-in-transit-with-mtls - // Step 2: Start accepting tasks on the `hello-world` queue await worker.run(); } - -run().catch((err) => { - console.error(err); - process.exit(1); -}); ``` + `taskQueue` is the only required option; however, use `workflowsPath` and `activities` to register Workflows and Activities with the Worker. -When scheduling a Workflow, you must specify `taskQueue`. +When you start a Workflow, set `taskQueue` to the name of the Task Queue that the Worker polls. + +[snippets/src/start-workflow.ts](https://github.com/temporalio/samples-typescript/blob/main/snippets/src/start-workflow.ts) ```ts import { Client, Connection } from '@temporalio/client'; -// This is the code that is used to start a Workflow. -const connection = await Connection.connect(); -const client = new Client({ connection }); -const result = await client.workflow.execute(yourWorkflow, { - // required - taskQueue: 'your-task-queue', - // required - workflowId: 'your-workflow-id', -}); -``` +import { loadClientConnectConfig } from '@temporalio/envconfig'; +import { nanoid } from 'nanoid'; +import { example } from './workflows'; -When creating a Worker, you must pass the `taskQueue` option to the `Worker.create()` function. +async function run() { + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); -```ts -const worker = await Worker.create({ - // imported elsewhere - activities, - taskQueue: 'your-task-queue', -}); + const handle = await client.workflow.start(example, { + // required + taskQueue: 'snippets', + // required + workflowId: 'workflow-' + nanoid(), + }); + console.log(`Started Workflow ${handle.workflowId}`); +} ``` + Optionally, in Workflow code, when calling an Activity, you can specify the Task Queue by passing the `taskQueue` option to `proxyActivities()`, `startChild()`, or `executeChild()`. If you do not specify `taskQueue`, the TypeScript SDK