temporalio / temporalio/sdk-typescript

[Feature Request] Add support for batched result retrieval executions

Open
#1,673 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
917
Forks
224
Avg merge
3d 16h
Merged PRs (30d)
43

Description

Is your feature request related to a problem? Please describe.

Hello,
for some reason need to create the report (CSV) from the ALL workflow execution results, how it looks now:

async function* fetchWorkflowExecutionResults({ workflowClient, namespace, companyId }) {
  let nextPageToken: Uint8Array | undefined;
  do {
        const workflows = await workflowClient.workflowService.listWorkflowExecutions({
            namespace,
            query: `ExecutionStatus="Completed" AND WorkflowType="createCompanyWorkflow" AND companyId="${companyId}`,
            nextPageToken,
        });
        nextPageToken = workflows.nextPageToken;

        for (const wf of workflows.executions) {
          const result = await workflowClient
                    .getHandle(wf.execution.workflowId, wf.execution.runId)
                    .result();
          yield {
            company_id: result.company_id,
            field1: result.field1,
            field2: result.field2,
            another_field: result.another_field,
          };
        }
  } while (nextPageToken?.byteLength);
}

it's working as expected for any amount of the executions, but it takes around ~1min to process 1000 executions, so for 1KK executions -> ~1000 minutes, which is not acceptable for my purposes.

Describe the solution you'd like

For faster processing, I can chunk workflows.executions (e.g., in batches of 50 or 100) using Promise.all(). However, I'm not sure if this is the correct behavior — it might make more sense to add a separate method for this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue's entry points are workflowService.listWorkflowExecutions and getHandle(...).result(); start by reviewing how these calls are used together in the provided generator. Define the batching behavior and its completion criteria, then validate retrieval across paginated executions and the requested performance improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.