Intermittent stalling on event with listener


#1

Hi all,
I’ve noticed intermittent token stalling (without incident/error) on an event/task that includes a start listener with javascript code. I tested the listener code as attached to a start event and a script task, with the same result. Sometimes the process executes this step successfully, and sometimes the token just stops there. When it stalls, I can see that the javascript did not execute properly, as the process instance variables are not updated (the variables referenced by the script are initially set with default values when the instance is started via API). Rebooting the camunda instance doesn’t move the token forward. The problem seems to go away for a little while if I make a change to the process and redeploy the process to camunda, and start a new instance, but eventually it comes back with later in future instances that are started.

Does anyone have any ideas about what might be causing this?

Here’s my bpmn code:

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1p6p4gp" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.11.3">
  <bpmn:collaboration id="Collaboration_0ovrvy3">
    <bpmn:participant id="Participant_0k1ov6l" name="test" processRef="test" />
  </bpmn:collaboration>
  <bpmn:process id="test" name="test" isExecutable="true">
    <bpmn:laneSet />
    <bpmn:sequenceFlow id="SequenceFlow_0ma955x" sourceRef="StartEvent_1ss3z1s" targetRef="Task_1yuyqu7" />
    <bpmn:startEvent id="StartEvent_1ss3z1s">
      <bpmn:outgoing>SequenceFlow_0ma955x</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:scriptTask id="Task_1yuyqu7" name="Step1" camunda:asyncBefore="true" scriptFormat="javascript">
      <bpmn:extensionElements>
        <camunda:executionListener event="start">
          <camunda:script scriptFormat="javascript"><![CDATA[// set bpm_action variable
// always set variables at the start, in case they're needed by this step
execution.setVariable("bpm_action", "01");

// set bpm_process_instance variable
var bpm_process_instance = execution.getProcessInstanceId();
execution.setVariable('bpm_process_instance', bpm_process_instance);

// set bpm_process_execution variable
var bpm_process_execution = execution.getId();
execution.setVariable('bpm_process_execution', bpm_process_execution);]]></camunda:script>
        </camunda:executionListener>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_0ma955x</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1q56ni8</bpmn:outgoing>
      <bpmn:script>// PLACEHOLDER</bpmn:script>
    </bpmn:scriptTask>
    <bpmn:endEvent id="EndEvent_1nk8npt">
      <bpmn:incoming>SequenceFlow_1q56ni8</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1q56ni8" sourceRef="Task_1yuyqu7" targetRef="EndEvent_1nk8npt" />
  </bpmn:process>
  <bpmn:signal id="Signal_0uwtf92" name="GetData-8598932356" />
  <bpmn:signal id="Signal_0rxxh4x" name="UpdateDatabase58269" />
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_0ovrvy3">
      <bpmndi:BPMNShape id="Participant_0k1ov6l_di" bpmnElement="Participant_0k1ov6l">
        <dc:Bounds x="-21" y="113" width="1182" height="682" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="StartEvent_1ss3z1s_di" bpmnElement="StartEvent_1ss3z1s">
        <dc:Bounds x="40" y="518" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="58" y="557" width="0" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0ma955x_di" bpmnElement="SequenceFlow_0ma955x">
        <di:waypoint xsi:type="dc:Point" x="58" y="518" />
        <di:waypoint xsi:type="dc:Point" x="58" y="471" />
        <di:waypoint xsi:type="dc:Point" x="127" y="471" />
        <di:waypoint xsi:type="dc:Point" x="127" y="437" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="47.5" y="449" width="90" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ScriptTask_0swsuqk_di" bpmnElement="Task_1yuyqu7">
        <dc:Bounds x="77" y="357" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="EndEvent_1nk8npt_di" bpmnElement="EndEvent_1nk8npt">
        <dc:Bounds x="255" y="379" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="273" y="418" width="0" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1q56ni8_di" bpmnElement="SequenceFlow_1q56ni8">
        <di:waypoint xsi:type="dc:Point" x="177" y="397" />
        <di:waypoint xsi:type="dc:Point" x="255" y="397" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="216" y="375" width="0" height="14" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Thanks!


#2

Update: I put a 3-second timer delay after the start event and now the token seems to not be stalling. I figure maybe the instance needs some time to start up before variables can be set, but that’s just a wild guess. Anyways, I hope this helps anyone who runs into this issue.