Skip to content

Commit 73aa017

Browse files
Merge pull request #36 from elasticio/sprint-33-issue-35
fix bug with incorrect await while emitting data
2 parents c72db56 + 6af4b7a commit 73aa017

15 files changed

+930
-534
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.4 (February 03, 2020)
2+
3+
* Fixed bug with incorrect await while emitting data
4+
15
## 1.0.3 (December 24, 2019)
26

37
* Update sailor version to 2.5.4

lib/actions/splitOnJsonata.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ async function processAction(msg, cfg) {
1818
return;
1919
}
2020

21-
const results = [];
22-
split.forEach((elem) => results.push(elem));
23-
this.logger.info('Splitting the incoming message into %s messages', results.length);
24-
results.forEach(async (result) => {
25-
if (result) {
26-
await this.emit('data', messages.newMessageWithBody(result));
21+
this.logger.info('Splitting the incoming message into %s messages', split.length);
22+
23+
for (let i = 0; i < split.length; i += 1) {
24+
if (split[i]) {
25+
// eslint-disable-next-line no-await-in-loop
26+
await this.emit('data', messages.newMessageWithBody(split[i]));
2727
}
28-
});
29-
await this.emit('end');
28+
}
3029
}
3130

3231
exports.process = processAction;

0 commit comments

Comments
 (0)