Skip to content

Commit 71304fc

Browse files
committed
fixing bugs
1 parent 5a886b8 commit 71304fc

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Supported:
106106
Limitations:
107107
* All groups must have one or more messages. (i.e. No groups of size 0).
108108
Can't do re-grouping when a split is done on an empty array. (i.e. No empty for each pattern supported).
109-
If all the messages in the group do not arrive, then the group will not be emitted..
109+
If all the messages in the group do not arrive, then the group will not be emitted.
110110
* The group is dropped if there are any unexpected restarts to the container.
111111
* In case only a groupSize is given and no delay timer is specified. The size of the group must be known by all group members.
112112
* In case of using the delay timer. Messages are only emitted when all parts arrive. Emitting a message only when the first part arrives isn't supported.

lib/actions/reassemble.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ async function timer(this_) {
1616
incomingData[message.messageId] = message.messageData;
1717
});
1818

19-
// eslint-disable-next-line no-await-in-loop
20-
await storage.deleteObjectById(groupList[i]);
21-
2219
// eslint-disable-next-line no-await-in-loop
2320
await this_.emit('data', messages.newMessageWithBody({
2421
groupSize: results.messages.length,
2522
groupId: results.messages[0].groupId,
2623
messageData: incomingData,
2724
}));
25+
// eslint-disable-next-line no-await-in-loop
26+
await storage.deleteObjectById(groupList[i]);
2827
}
2928
}
3029

@@ -105,29 +104,23 @@ async function processAction(msg, cfg) {
105104

106105
// When delay timer option is selected
107106
if (mode === 'timeout') {
108-
delay = msg.body.timersec;
109107
delay = (msg.body.timersec >= 40000) ? 40000 : msg.body.timersec;
110108
clearTimeout(timeHandle);
111109
timeHandle = setTimeout(timer, delay, this);
112-
if (groupList.includes(messageGroupId)) {
113-
// no action required
114-
} else {
110+
if (!groupList.includes(messageGroupId)) {
115111
groupList.push(messageGroupId);
116-
}
112+
}
117113
}
118114

119115
// When both groupSize and delay timer option is selected
120116
if (mode === 'groupSize&timeout') {
121-
delay = msg.body.timersec;
122117
delay = (msg.body.timersec >= 40000) ? 40000 : msg.body.timersec;
123118
clearTimeout(timeHandle);
124119
timeHandle = setTimeout(timer, delay, this);
125120

126-
if (groupList.includes(messageGroupId)) {
127-
// no action required
128-
} else {
121+
if (!groupList.includes(messageGroupId)) {
129122
groupList.push(messageGroupId);
130-
}
123+
}
131124

132125
if (messagesNumberSeen >= messageGroupSize) {
133126
parsedMessageGroup.messages.forEach((message) => {

0 commit comments

Comments
 (0)