After clicking on the “Complete” button in a user task, it doesn’t disappear until the process is finished or reaching another user task.
I have reduced my case to the minimum in order to test it :
When clicking on “Complete” in the user task form, it is deactivated and I can’t perform anymore actions on it, but the task remains while the rest of the process is executed.
Moreover, if I change task and come back to this one, I can click again, and then an error is thrown after a while, saying that the entity was updated by another transaction concurrently.
Even in the Cockpit, I don’t see the process instance leave the user task activity until the script is over (which is just sleep(10000)).
How can I avoid this behavior, and have the task to disappear as soon as it’s completed ?
Once the user task has been completed the process engine will drive the process forward until the next wait state - which in the case above is until the process instance is completed. This will take place in a single transaction and that’s why it appears as if the user task has not been completed yet.
If you mark the “Wait” script task as “Asynchronous before” in the Modeler, it marks a wait state which means that once the user task has been completed the process engine will commit the state and the task is now completed. The process engine job executor will then eventually pick up the “Wait” script task and drive the process forward from there - in that transaction and until the next wait state is reached.