External workers double executing with camunda-external-task-client-js

Hi everyone,

I’m using camunda-external-task-client-js with camunda/camunda-bpm-platform:run-7.16.0 and have run into an issue with external workers occasionally double executing tasks.

My handler code follows this general form…

const handler = async ({ task, taskService }: HandlerArgs) => {
  await taskService.extendLock(task, 10000); 
  try {
    // do work
    await taskService.complete(task, processVariables, localVariables);
  } catch (err) {
    await taskService.handleFailure(task, {/* options */});
  }
};

External Task Client | docs.camunda.org states

The lock duration can only be extended, if the External Task is currently locked by the client.

However, that is not what I’m observing. The external workers, at times, will output this…

✓ handled extend lock of task 8a78c676-acab-11ee-b10f-0242ac110002
✓ handled extend lock of task 8a78c676-acab-11ee-b10f-0242ac110002
✓ completed task 8a78c676-acab-11ee-b10f-0242ac11
✖ couldn't complete task 8a78c676-acab-11ee-b10f-0242ac110002, EngineError: Response code 404 (Not Found); Error: External task with id 8a78c676-acab-11ee-b10f-0242ac110002 does not exist; Type: RestException; Code: undefined

Any help or thoughts on this would be greatly appreciated!

-Ben