Uncaught (in promise): "function is not iterable" when using preact inside properties panel

Hi,

I’m using the properties panel along with async extensions that I implemented using the example on github (bpmn-js-examples/properties-panel-async-extension at main · bpmn-io/bpmn-js-examples · GitHub). So I have a custom provider that collects all the groups. Inside the groups I use preact hooks for the asynchronous properties.

Example for an async call inside a group (added for call activities):

export default function (args) {

  const {element} = args;

  const [values, setValues] = useState({});

  useEffect(() => {
    if (!values.diagrams) {
      getDiagrams().then(diagrams => setValues((existing) => { return {...existing, diagrams: diagrams}; }));
    }
  }, [element.id]);

  const {diagrams} = values;

  const entries = [];

  // use diagrams for a select list and add this to entries

  return entries;

I used the object syntax in the return value so I can re-use the same data over multiple properties, which worked fine so far.

Now I’ve updated the dependencies of @bpmn-io/properties-panel and
bpmn-js-properties-panel to the latest version and now I get an error, as soon as I place an element on the canvas that uses this group.

Error message in the console:

Uncaught (in promise) TypeError: function is not iterable (cannot read property Symbol(Symbol.iterator))
    at b.BpmnPropertiesPanel [as constructor] (index.esm.js:1605:43)

That leads to the following part inside bpmn-js-properties-panel:

// (5) notify layout changes
  const [layoutConfig, setLayoutConfig] = useState(initialLayoutConfig || {});
  const onLayoutChanged = useCallback(newLayout => {
    eventBus.fire('propertiesPanel.layoutChanged', {
      layout: newLayout
    });
  }, [eventBus]);

If I’m correct that change came in version 1.21.0, I was below that version before, so that would fit.

I can’t find out, why this error comes up now and even more, why only at this position. I use the same syntax on a property group on process level - so it gets executed directly on loading a diagram, which works fine - and also on other elements, but there dependant on another property which has to be selected first, so this doesn’t get executed directly when adding the object.

So my assumption would be, that it’s some kind of timing issue or that the useEffect calls block each other, but I don’t really see a way around for that here.

Any help or ideas welcome :slight_smile:

Hi,

Without your specific implementation it is hard for us to reproduce the error. Can you please either share your project or a running example that reproduces the issue you are facing?

Thanks :heart:

Yes sure, and sorry for the late response.

The project can be found here: GitHub - flowsforapex/bpmn-modeler at feature/extended-properties

Implementation is inside apexPropertiesProvider/new_provider/parts/callActivity
for the useState/useEffect calls and apexPropertiesProvider/new_provider/plugins/metaDataCollector
which will return a dummy result for the async calls for testing purposes.

Still struggeling with this error, I really don’t want to go back to a previous version, where it still worked, because of that :frowning:

Any help, where to look for a solution, ideas to try out, anything, would be great.