bpmn-io / bpmn-js

A BPMN 2.0 rendering toolkit and web modeler.

Home Page:https://bpmn.io/toolkit/bpmn-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Loading a simple BPMN with a swimlane results in TypeError: Cannot read properties of undefined (reading 'bpmnElement')

nitram509 opened this issue · comments

Describe the Bug

I did an upgrade from v6.5.1 to the latest v.16.4.0.
When loading a simple BPMN I got the error TypeError: Cannot read properties of undefined (reading 'bpmnElement')

Any help is appreciated.

Steps to Reproduce

  1. this is my app.js (relevant code snippet)
      var BpmnViewer = window.BpmnJS;
      viewer = new BpmnViewer({container: '#diagramCanvas', width: '100%', height: '100%'});

      canvas = viewer.get('canvas');
      eventBus = viewer.get("eventBus");
      overlays = viewer.get("overlays");

      var xmlString = "...see XML below...."
      viewer.importXML(xmlString, function(err) { /* ... */ });

The Error

bpmn-navigated-viewer.production.min.js:2 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'bpmnElement')
    at bpmn-navigated-viewer.production.min.js:2:175573
    at l (bpmn-navigated-viewer.production.min.js:7:459)
    at bpmn-navigated-viewer.production.min.js:7:819
    at new Promise (<anonymous>)
    at Or (bpmn-navigated-viewer.production.min.js:7:652)
    at Gr.open (bpmn-navigated-viewer.production.min.js:22:1863)
    at Gr.importDefinitions (bpmn-navigated-viewer.production.min.js:22:1450)
    at Gr.importXML (bpmn-navigated-viewer.production.min.js:22:894)

The BPMN

Screenshot 2024-01-24 at 21 42 59

<?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:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_18z5blu" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.18.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.3.0">
  <bpmn:collaboration id="Collaboration_1g2wvjc">
    <bpmn:participant id="Participant_0mh2pw5" processRef="Process_04itp17" />
  </bpmn:collaboration>
  <bpmn:process id="Process_04itp17" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>Flow_0x47u4c</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="Flow_0x47u4c" sourceRef="StartEvent_1" targetRef="Activity_0efhwma" />
    <bpmn:endEvent id="Event_1ahiem1">
      <bpmn:incoming>Flow_0lbkyot</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="Flow_0lbkyot" sourceRef="Activity_0efhwma" targetRef="Event_1ahiem1" />
    <bpmn:serviceTask id="Activity_0efhwma" name="hello-world">
      <bpmn:extensionElements>
        <zeebe:taskDefinition type="hello-world" />
      </bpmn:extensionElements>
      <bpmn:incoming>Flow_0x47u4c</bpmn:incoming>
      <bpmn:outgoing>Flow_0lbkyot</bpmn:outgoing>
    </bpmn:serviceTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1g2wvjc">
      <bpmndi:BPMNShape id="Participant_0mh2pw5_di" bpmnElement="Participant_0mh2pw5" isHorizontal="true">
        <dc:Bounds x="120" y="52" width="600" height="250" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="179" y="159" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Event_1ahiem1_di" bpmnElement="Event_1ahiem1">
        <dc:Bounds x="432" y="159" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Activity_1lm1uup_di" bpmnElement="Activity_0efhwma">
        <dc:Bounds x="270" y="137" width="100" height="80" />
        <bpmndi:BPMNLabel />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_0x47u4c_di" bpmnElement="Flow_0x47u4c">
        <di:waypoint x="215" y="177" />
        <di:waypoint x="270" y="177" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_0lbkyot_di" bpmnElement="Flow_0lbkyot">
        <di:waypoint x="370" y="177" />
        <di:waypoint x="432" y="177" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

Expected Behavior

Loading a simple BPMN from XML should just work.

Environment

  • Browser: Chrome, latest version
  • OS: OSX, latest version
  • Library version: bpmn-js - bpmn-navigated-viewer v16.4.0

@nitram509 As you upgraded across 10 major versions did you read through the changelog and see if any of the breaking changes affect you? There is only a few as our tools are very stable, usually.

Alternatively, ignoring the changelog, you could update step by step and see exactly where it breaks and/or if deprecation warnings pop up?

@nitram509 As you upgraded across 10 major versions did you read through the changelog and see if any of the breaking changes affect you? There is only a few as our tools are very stable, usually.

Alternatively, ignoring the changelog, you could update step by step and see exactly where it breaks and/or if deprecation warnings pop up?

@nikku I'm aware of the "large" upgrade.
Looking at the starter code snippets provided (e.g. https://github.com/bpmn-io/bpmn-js-examples/blob/main/starter/viewer.html),
I consider my above code snippet still fine and consider the loading issue a problem in the library.
That said, there could be some other API changes down the road, yes - but the XML/BPMN is not even loading yet.

Don't you think so?

Regards
Martin

After further evaluation I don't think it's a lib issue ... will need to dive deeper an close this for now.

My advice remains:

  • Read through the CHANGELOG to indentify breaking changes and if they could impact your usage.
  • Bisect (i.e. upgrade gradually) to identify in which tool version this breaks, then get back to the CHANGELOG to understand why.