bpmn-io / bpmn-js-token-simulation

A BPMN 2.0 specification compliant token simulator.
https://bpmn-io.github.io/bpmn-js-token-simulation/modeler.html?e=1&pp=1
MIT License
243 stars 69 forks source link

fix: undefined eventDefinitions on some elements #171

Closed dgkm closed 2 months ago

dgkm commented 2 months ago

This MR is fixing the businessObject.eventDefinitions undefined exception received on some elements.

Fix for events failing at bo.eventDefinitions.length as undefined on some elements.

CLAassistant commented 2 months ago

CLA assistant check
All committers have signed the CLA.

nikku commented 2 months ago

@dgkm Please provide me with a diagram that reproduces the issue in the first place. I'd consider (if possible) to add a test case, too.

dgkm commented 2 months ago

I couldn't reproduce this on the online demo or the example application.

In my local environment I'm facing issues on your example bpmn itself. I have BPMN modeler integrated with a react app and I'm facing the issue.

Please refer to the debug screen showing the bo.eventDefinitions as undefined

image

This is the example flow I'm referring to where I was able to reproduce this on my local environment:

image

If you need any further information then please let me know.

philippfromme commented 2 months ago

I think it's generally a good idea to guard against eventDefinitions not existing. This issue can also be fixed by using bo.get('eventDefinitions') which will always return an array since eventDefinitions is defined as isMany = true. In any case we'd want a test case verifying the fix.

dgkm commented 2 months ago

bo.get('eventDefinitions')

@philippfromme , perfect, it is actually working when I watch bo.get('eventDefinitions') in debug mode. Accordingly I have modified the fix to use bo.get('eventDefinitions').length in place of bo.eventDefinitions.length.

I hope you can continue with this.

nikku commented 2 months ago

Thanks for the improvement @dgkm :slightly_smiling_face:

nikku commented 2 months ago

Released with v0.34.1.