I am trying to use WorkflowClient#list (Server: 1.24.2) to return the workflow executions but I am not successful at controlling the result when setting the pageSize
. I must be doing something wrong.
As an example of my confusion, I have modified the hello-world-js/src/client.js to start three workflows and then call list
with a pageSize: 1
. Below is an example of what I tried (unchanged code has been omitted):
...
// Start three workflows
const names = ['Temporal1','Temporal2','Temporal3']
names.forEach(async name => {
// Invoke the `example` Workflow, only resolved when the workflow completes
const result = await client.workflow.execute(example, {
taskQueue: 'hello-javascript',
workflowId: `my-business-id (${name})`,
args: [name],
});
console.log(result); // Hello, Temporal!
});
// Get the list of workflows asking for only one
const n = 1
const asyncWfIter = client.workflow.list({pageSize: n})
for await (const wfExecInfo of asyncWfIter) {
console.log(`Print List({pageSize: ${n}} }) : ${wfExecInfo.workflowId}`)
}
}
...
The results:
npm run workflow
> hello-world-js@0.1.0 workflow
> node src/client.js
Print List({pageSize: 1} }) : my-business-id (Temporal3)
Print List({pageSize: 1} }) : my-business-id (Temporal1)
Print List({pageSize: 1} }) : my-business-id (Temporal2)
Hello, Temporal2!
Hello, Temporal1!
Hello, Temporal3
Thank you.