elasticio / jsonata-transform-component

Dedicated data transformation component for elastic.io platform based on JSONata
Apache License 2.0
3 stars 5 forks source link

Component does not await correctly when emitting data #28

Closed jhorbulyk closed 4 years ago

jhorbulyk commented 4 years ago

from: splitter-component/lib/actions/splitOnJsonata.js

results.forEach(async (result) => {
        if (result) {
            await this.emit('data', messages.newMessageWithBody(result));
        }
    });

This code does not handle asynchronous call emit correctly. see e.g. here: https://stackoverflow.com/questions/37576685/are-there-any-issues-with-using-async-await-in-a-foreach-loop It should be replaced with either for (... of ...) {await ...} so that:

jhorbulyk commented 4 years ago

Bug affects splitter component not transform component.