Current Activity Not Showing Correctly In Cockpit or via REST API

We are running Camunda 7.9.0.

We believe we are seeing an issue where the currently running activity (which in this case is a script task) is not properly shown in the Cockpit, nor is not returned via the REST API when calling GET engine-rest/process-instance/:id/activity-instances.

This can be demonstrated with a very simple model consisting of a user task, followed by a script task (in this case, the script consists of an infinite loop, in order to keep this task active). NOTE: The user task is configured with Asynchronous After enabled.

testAsyncContinue2.bpmn (3.5 KB)

After starting the process and completing the user task, in the Cockpit, on the Processes page, the view of the model shows the token still sitting on the user task, even though the user task has been completed. In the User Tasks tab beneath the model image, no user tasks are listed, which is correct. So this view is inconsistent. See the following screen shot:

When issuing the REST API call GET engine-rest/process-instance/:id/activity-instances, the following is returned:

    "id": "d46fd003-ac87-11e8-b3b5-0242ac120003",
    "parentActivityInstanceId": null,
    "activityId": "TestAsync:1:a95480ee-ac87-11e8-b3b5-0242ac120003",
    "activityType": "processDefinition",
    "processInstanceId": "d46fd003-ac87-11e8-b3b5-0242ac120003",
    "processDefinitionId": "TestAsync:1:a95480ee-ac87-11e8-b3b5-0242ac120003",
    "childActivityInstances": [],
    "childTransitionInstances": [
            "id": "d46fd003-ac87-11e8-b3b5-0242ac120003",
            "parentActivityInstanceId": "d46fd003-ac87-11e8-b3b5-0242ac120003",
            "processInstanceId": "d46fd003-ac87-11e8-b3b5-0242ac120003",
            "processDefinitionId": "TestAsync:1:a95480ee-ac87-11e8-b3b5-0242ac120003",
            "activityId": "Task_15rkevu",
            "activityName": "Test Async User Task",
            "activityType": "userTask",
            "executionId": "d46fd003-ac87-11e8-b3b5-0242ac120003",
            "targetActivityId": "Task_15rkevu"
    "executionIds": [
    "activityName": "Test Async",
    "name": "Test Async"

This shows the already completed user task as a current activity. It does not show the script task as a current activity.

As expected, the DB table ACT_RU_TASK does not show any current tasks for this process instance.

Is this expected behavior? Clearly the Cockpit display appears to be inconsistent and the REST endpoint is returning an activity that has been completed. I would expect both to show that the script task is the current activity.

Is there some other REST API call we should be using that would accurately show that the script task is currently executing?

This is expected behavior.
What you see in cockpit is the last known consistent state - according to the database. After you complete the user task the the script task is being run in memory. The state will not move forward until the process reaches a wait state or a transaction boundary.

While you might see the token on the user task - this does not mean that the task has not been completed. The fact that you’ve added an a-sync after on that means that after the task has been completed the state is committed. So the state of the process would show that no user task exists in the database but the last known consistent state was on that symbol.

If you want to see that you’ve actually reached the script task then you’ll need to add an a-sync before on the script task.

1 Like

Thank you for the explanation. I understand this. But I do find that having to add async before to any service tasks that we want to see as the currently running task seems somewhat inconvenient.

Somewhat more troubling is the fact that the completed user task is still returned in the call to GET engine-rest/process-instance/:id/activity-instances, even though it has been completed and synced.

1 Like

Generally service tasks and script tasks (depending on their implementation) don’t last much longer than a few milliseconds, so it’s not really an issue for most people - but if you have longer running code and want to make sure you know if it’s started or in progress then you can use the External Task Pattern - this would mean that there would be a wait state before all service tasks.

The fact that the execution (i.e. the token) is on a completed task shouldn’t be an issue because if you really wanted to know about what tasks are currently available to be completed you just need to query for tasks not for activity instances.
Also the true state of the process is in fact on that completed task - because you’ve added and a-sync on it. If you don’t want the token to appear there after the task is completed simply remove it.

Hi Niall,

As per your explanation, it should always show last completed task in cockpit. But actually it doesn’t show like that.
For example, my process is something like this.

Here Get Customer is an external service and Validate and Update are Rest Service.
So either my token getting shown on Get Customer or nowhere.

If in case my Update Customer service task gets failed. Validate Customer is again and again gets invoked in an infinite loop until and unless there is some connection disruption.

So Basically I am facing 2 issues here - Not actual consistent state,

  • Infinite loop call.

All tasks are synchronous here.

Add asyncronous before to the Validate Customer service task. That will ensure that if the Get Customer task is completed successfully it will not roll back due to a failure in the Validate Customer task.