Hi, I’m using Camunda 8.6.7 to design a process.
- I use a Worker Service in Node.js with
@camunda8/sdk.
I’m designing a process similar to the diagram above (this is just an example, not the real process).
Node.js:
- API:
/start { word, apikey }
→ Calls Camunda Start Event - API:
/translate { actions: [ { from: 'en', to: 'thai' }, ... ] }
Process Flow:
Start Event → Check Permission → Call Webhook API (send action list) → User Task → Handle → End
Code (complete user task):
ts
CopyEdit
async completeTask(processInstanceKey: string) {
const camunda = this._client;
const tasks = await camunda.getTasklistApiClient().searchTasks({
processInstanceKey,
taskDefinitionId: process.env.USER_SELECT_LANGUAGE_TASK
});
const task = tasks[0];
if (!task) {
throw new NotFoundException('Not found task');
}
return camunda.getTasklistApiClient().completeTask(task.id);
}
My Issue:
- After calling the webhook API (to send the action list to the backend → then emit via socket to the frontend),
- The user clicks on actions in the frontend and sends them to the backend → this triggers the
/translateAPI call. - However, for some reason, the User Task (with activity ID
taskDefinitionId: process.env.USER_SELECT_LANGUAGE_TASK) has not yet been created, so the process seems to pause, and an error is returned to the frontend. - I’ve tried using recursion to retry
searchTasks(5 times, 5 seconds apart), but I don’t think this is a good solution.
