Multi-instance (parallel) external tasks are getting stuck - JavaScript edition

There seems to be an issue when processing Multi-instance (parallel) External task from JavaScript (note: I have not tried the same from Java; note 2: it works fine if Multitask Two is set as sequential).
I created a simple BPMN to show the problem:

Task One is an External Service call that returns simple array of strings, fruit_list: [“Apples”, “Oranges”, “Bananas”]
Multitask Two is an External Service call that iterates over the fruit_list with fruit_item as element variable.

When I execute javascript to process this workflow, I get following error for the 2 out of 3 instances of Multitask Two:
ENGINE-03005 Execution of 'UPDATE VariableInstanceEntity[1ae78ba3-7f43-11ea-a21b-90324b38fccc]' failed. Entity was updated by another transaction concurrently.

All 3 instances in JavaScript code that were subscribed to the topic are executed successfully.

See attached for the full code (BPMN)

MultiItemTest.bpmn (3.6 KB)

const { Variables } = require("camunda-external-task-client-js");
const { Client, logger } = require("camunda-external-task-client-js");
const config = { baseUrl: "http://localhost:8080/engine-rest", use: logger };
const client = new Client(config);
client.subscribe("taskOneTopic", async function({ task, taskService }) {

	try{
		console.log("in taskOneTopic");

		var businessKey = task.businessKey;
		console.log('business Key: ' + businessKey);

		var string_list = [];
		string_list.push("Apples");
		string_list.push("Oranges");
		string_list.push("Bananas");
		let str_list = JSON.stringify(string_list);
		console.log(str_list);

		const processVariables = new Variables();
		processVariables.setTyped("fruit_list", {
			value: str_list,
			type:"Object",
			valueInfo: {
				objectTypeName:"java.util.ArrayList",
				serializationDataFormat:"application/json"
			}
		  });
		await taskService.complete(task, processVariables);
	}
	catch (err){
		console.log("error executing taskOneTopic");
		console.log(err);
	}
});


client.subscribe("multitaskTwoTopic", async function({ task, taskService }) {

	try{
		console.log("in multitaskTwoTopic");
		var businessKey = task.businessKey;
		console.log('business Key: ' + businessKey);

		var txnList = task.variables.get("fruit_list");
		console.log('fruit_list list: ' + txnList);
		
		const fruit_item = task.variables.get("fruit_item");
		console.log('PROCESSING fruit_item: ' + fruit_item);

		await taskService.complete(task);
	}
	catch(err){
		console.log("error executing multitaskTwoTopic");
		console.log(err);
	}
});

Full javascript output:

polling
✓ subscribed to topic taskOneTopic
✓ subscribed to topic multitaskTwoTopic
polling
✓ polled 1 tasks
in taskOneTopic
business Key: 174
[“Apples”,“Oranges”,“Bananas”]
✓ completed task 07af3337-7f43-11ea-a21b-90324b38fccc
polling
✓ polled 3 tasks
in multitaskTwoTopic
business Key: 174
fruit_list list: [“Apples”,“Oranges”,“Bananas”]
PROCESSING fruit_item: Apples
in multitaskTwoTopic
business Key: 174
fruit_list list: [“Apples”,“Oranges”,“Bananas”]
PROCESSING fruit_item: Oranges
in multitaskTwoTopic
business Key: 174
fruit_list list: [“Apples”,“Oranges”,“Bananas”]
PROCESSING fruit_item: Bananas
✓ completed task 1ae78bbc-7f43-11ea-a21b-90324b38fccc
:heavy_multiplication_x: couldn’t complete task 1ae78bb8-7f43-11ea-a21b-90324b38fccc, ENGINE-03005 Execution of ‘UPDATE VariableInstanceEntity[1ae78ba3-7f43-11ea-a21b-90324b38fccc]’ failed. Entity was updated by another transaction concurrently.
:heavy_multiplication_x: couldn’t complete task 1ae78bc0-7f43-11ea-a21b-90324b38fccc, ENGINE-03005 Execution of ‘UPDATE VariableInstanceEntity[1ae78ba3-7f43-11ea-a21b-90324b38fccc]’ failed. Entity was updated by another transaction concurrently.
polling
✓ polled 0 tasks

I was experiencing the same issue. Here is the solution: