bpmn-elements 14.0.1 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +0 -4
  2. package/dist/Context.js +41 -35
  3. package/dist/Environment.js +1 -1
  4. package/dist/Expressions.js +1 -1
  5. package/dist/MessageFormatter.js +0 -1
  6. package/dist/Timers.js +5 -9
  7. package/dist/Tracker.js +15 -19
  8. package/dist/activity/Activity.js +17 -11
  9. package/dist/activity/ActivityExecution.js +43 -29
  10. package/dist/definition/Definition.js +1 -1
  11. package/dist/definition/DefinitionExecution.js +64 -55
  12. package/dist/eventDefinitions/EscalationEventDefinition.js +1 -1
  13. package/dist/eventDefinitions/LinkEventDefinition.js +1 -1
  14. package/dist/eventDefinitions/MessageEventDefinition.js +1 -1
  15. package/dist/eventDefinitions/SignalEventDefinition.js +3 -2
  16. package/dist/events/BoundaryEvent.js +11 -9
  17. package/dist/events/EndEvent.js +1 -1
  18. package/dist/events/IntermediateCatchEvent.js +1 -1
  19. package/dist/events/IntermediateThrowEvent.js +1 -1
  20. package/dist/events/StartEvent.js +1 -1
  21. package/dist/flows/SequenceFlow.js +1 -1
  22. package/dist/gateways/EventBasedGateway.js +1 -1
  23. package/dist/gateways/ExclusiveGateway.js +1 -1
  24. package/dist/gateways/InclusiveGateway.js +1 -1
  25. package/dist/gateways/ParallelGateway.js +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/io/InputOutputSpecification.js +1 -1
  28. package/dist/io/Properties.js +1 -1
  29. package/dist/process/Process.js +1 -1
  30. package/dist/process/ProcessExecution.js +67 -40
  31. package/dist/tasks/CallActivity.js +1 -1
  32. package/dist/tasks/LoopCharacteristics.js +2 -2
  33. package/dist/tasks/ReceiveTask.js +1 -1
  34. package/dist/tasks/ScriptTask.js +1 -1
  35. package/dist/tasks/ServiceImplementation.js +1 -1
  36. package/dist/tasks/ServiceTask.js +1 -1
  37. package/dist/tasks/SignalTask.js +1 -1
  38. package/dist/tasks/StandardLoopCharacteristics.js +1 -1
  39. package/dist/tasks/SubProcess.js +27 -28
  40. package/dist/tasks/Task.js +1 -1
  41. package/dist/tasks/Transaction.js +1 -1
  42. package/package.json +5 -3
  43. package/src/Context.js +51 -35
  44. package/src/MessageFormatter.js +0 -3
  45. package/src/Timers.js +5 -9
  46. package/src/Tracker.js +13 -17
  47. package/src/activity/Activity.js +5 -3
  48. package/src/activity/ActivityExecution.js +43 -26
  49. package/src/definition/DefinitionExecution.js +64 -54
  50. package/src/eventDefinitions/SignalEventDefinition.js +1 -1
  51. package/src/events/BoundaryEvent.js +10 -8
  52. package/src/process/ProcessExecution.js +70 -40
  53. package/src/tasks/LoopCharacteristics.js +2 -2
  54. package/src/tasks/SubProcess.js +27 -27
  55. package/types/types.d.ts +1 -1
package/src/Context.js CHANGED
@@ -20,17 +20,15 @@ function ContextInstance(definitionContext, environment, owner) {
20
20
  this.definitionContext = definitionContext;
21
21
  this.environment = environment;
22
22
  this.extensionsMapper = new ExtensionsMapper(this);
23
- this.refs = {
24
- activityRefs: {},
25
- associationRefs: [],
26
- dataObjectRefs: {},
27
- dataStoreRefs: {},
28
- messageFlows: [],
29
- processes: [],
30
- processRefs: {},
31
- sequenceFlowRefs: {},
32
- sequenceFlows: [],
33
- };
23
+ this.refs = new Map([
24
+ ['activityRefs', new Map()],
25
+ ['sequenceFlowRefs', new Map()],
26
+ ['processRefs', new Map()],
27
+ ['messageFlows', new Set()],
28
+ ['associationRefs', new Map()],
29
+ ['dataObjectRefs', new Map()],
30
+ ['dataStoreRefs', new Map()],
31
+ ]);
34
32
  this[kOwner] = owner;
35
33
  }
36
34
 
@@ -41,7 +39,7 @@ Object.defineProperty(ContextInstance.prototype, 'owner', {
41
39
  });
42
40
 
43
41
  ContextInstance.prototype.getActivityById = function getActivityById(activityId) {
44
- const activityInstance = this.refs.activityRefs[activityId];
42
+ const activityInstance = this.refs.get('activityRefs').get(activityId);
45
43
  if (activityInstance) return activityInstance;
46
44
  const activity = this.definitionContext.getActivityById(activityId);
47
45
  if (!activity) return null;
@@ -49,16 +47,17 @@ ContextInstance.prototype.getActivityById = function getActivityById(activityId)
49
47
  };
50
48
 
51
49
  ContextInstance.prototype.upsertActivity = function upsertActivity(activityDef) {
52
- let activityInstance = this.refs.activityRefs[activityDef.id];
50
+ let activityInstance = this.refs.get('activityRefs').get(activityDef.id);
53
51
  if (activityInstance) return activityInstance;
54
52
 
55
- activityInstance = this.refs.activityRefs[activityDef.id] = new activityDef.Behaviour(activityDef, this);
53
+ activityInstance = new activityDef.Behaviour(activityDef, this);
54
+ this.refs.get('activityRefs').set(activityDef.id, activityInstance);
56
55
 
57
56
  return activityInstance;
58
57
  };
59
58
 
60
59
  ContextInstance.prototype.getSequenceFlowById = function getSequenceFlowById(sequenceFlowId) {
61
- const flowInstance = this.refs.sequenceFlowRefs[sequenceFlowId];
60
+ const flowInstance = this.refs.get('sequenceFlowRefs').get(sequenceFlowId);
62
61
  if (flowInstance) return flowInstance;
63
62
 
64
63
  const flowDef = this.definitionContext.getSequenceFlowById(sequenceFlowId);
@@ -91,12 +90,12 @@ ContextInstance.prototype.getSequenceFlows = function getSequenceFlows(scopeId)
91
90
  };
92
91
 
93
92
  ContextInstance.prototype.upsertSequenceFlow = function upsertSequenceFlow(flowDefinition) {
94
- const refs = this.refs.sequenceFlowRefs;
95
- let flowInstance = refs[flowDefinition.id];
93
+ const sequenceFlowRefs = this.refs.get('sequenceFlowRefs');
94
+ let flowInstance = sequenceFlowRefs.get(flowDefinition.id);
96
95
  if (flowInstance) return flowInstance;
97
96
 
98
- flowInstance = refs[flowDefinition.id] = new flowDefinition.Behaviour(flowDefinition, this);
99
- this.refs.sequenceFlows.push(flowInstance);
97
+ flowInstance = new flowDefinition.Behaviour(flowDefinition, this);
98
+ sequenceFlowRefs.set(flowDefinition.id, flowInstance);
100
99
 
101
100
  return flowInstance;
102
101
  };
@@ -106,11 +105,13 @@ ContextInstance.prototype.getAssociations = function getAssociations(scopeId) {
106
105
  };
107
106
 
108
107
  ContextInstance.prototype.upsertAssociation = function upsertAssociation(associationDefinition) {
109
- const refs = this.refs.associationRefs;
110
- let instance = refs[associationDefinition.id];
108
+ const associationRefs = this.refs.get('associationRefs');
109
+ let instance = associationRefs.get(associationDefinition.id);
111
110
  if (instance) return instance;
112
111
 
113
- instance = refs[associationDefinition.id] = new associationDefinition.Behaviour(associationDefinition, this);
112
+ instance = new associationDefinition.Behaviour(associationDefinition, this);
113
+
114
+ associationRefs.set(associationDefinition.id, instance);
114
115
 
115
116
  return instance;
116
117
  };
@@ -120,19 +121,18 @@ ContextInstance.prototype.clone = function clone(newEnvironment, newOwner) {
120
121
  };
121
122
 
122
123
  ContextInstance.prototype.getProcessById = function getProcessById(processId) {
123
- const refs = this.refs.processRefs;
124
- let bp = this.refs.processRefs[processId];
124
+ const processRefs = this.refs.get('processRefs');
125
+ let bp = processRefs.get(processId);
125
126
  if (bp) return bp;
126
127
 
127
128
  const processDefinition = this.definitionContext.getProcessById(processId);
128
129
  if (!processDefinition) return null;
129
130
 
130
131
  const bpContext = this.clone(this.environment.clone());
131
- bp = refs[processId] = new processDefinition.Behaviour(processDefinition, bpContext);
132
+ bp = new processDefinition.Behaviour(processDefinition, bpContext);
133
+ processRefs.set(processId, bp);
132
134
  bpContext[kOwner] = bp;
133
135
 
134
- this.refs.processes.push(bp);
135
-
136
136
  return bp;
137
137
  };
138
138
 
@@ -156,35 +156,51 @@ ContextInstance.prototype.getExecutableProcesses = function getExecutableProcess
156
156
  };
157
157
 
158
158
  ContextInstance.prototype.getMessageFlows = function getMessageFlows(sourceId) {
159
- if (!this.refs.messageFlows.length) {
160
- const flows = this.definitionContext.getMessageFlows() || [];
161
- this.refs.messageFlows.push(...flows.map((flow) => new flow.Behaviour(flow, this)));
159
+ const messageFlowRefs = this.refs.get('messageFlows');
160
+
161
+ const result = [];
162
+ if (!messageFlowRefs.size) {
163
+ const msgFlows = this.definitionContext.getMessageFlows() || [];
164
+ for (const msgFlow of msgFlows) {
165
+ const flow = new msgFlow.Behaviour(msgFlow, this);
166
+ messageFlowRefs.add(flow);
167
+
168
+ if (flow.source.processId === sourceId) result.push(flow);
169
+ }
170
+ } else {
171
+ for (const flow of messageFlowRefs) {
172
+ if (flow.source.processId === sourceId) result.push(flow);
173
+ }
162
174
  }
163
175
 
164
- return this.refs.messageFlows.filter((flow) => flow.source.processId === sourceId);
176
+ return result;
165
177
  };
166
178
 
167
179
  ContextInstance.prototype.getDataObjectById = function getDataObjectById(referenceId) {
180
+ const dataObjectRefs = this.refs.get('dataObjectRefs');
168
181
  let dataObject;
169
- if ((dataObject = this.refs.dataObjectRefs[referenceId])) return dataObject;
182
+ if ((dataObject = dataObjectRefs.get(referenceId))) return dataObject;
170
183
 
171
184
  const dataObjectDef = this.definitionContext.getDataObjectById(referenceId);
172
185
  if (!dataObjectDef) return;
173
186
 
174
- dataObject = this.refs.dataObjectRefs[dataObjectDef.id] = new dataObjectDef.Behaviour(dataObjectDef, this);
187
+ dataObject = new dataObjectDef.Behaviour(dataObjectDef, this);
188
+ dataObjectRefs.set(dataObjectDef.id, dataObject);
175
189
 
176
190
  return dataObject;
177
191
  };
178
192
 
179
193
  ContextInstance.prototype.getDataStoreById = function getDataStoreById(referenceId) {
194
+ const dataStoreRefs = this.refs.get('dataStoreRefs');
180
195
  let dataStore;
181
- if ((dataStore = this.refs.dataStoreRefs[referenceId])) return dataStore;
196
+ if ((dataStore = dataStoreRefs.get(referenceId))) return dataStore;
182
197
 
183
198
  const dataStoreDef =
184
199
  this.definitionContext.getDataStoreById(referenceId) || this.definitionContext.getDataStoreReferenceById(referenceId);
185
200
  if (!dataStoreDef) return;
186
201
 
187
- dataStore = this.refs.dataStoreRefs[dataStoreDef.id] = new dataStoreDef.Behaviour(dataStoreDef, this);
202
+ dataStore = new dataStoreDef.Behaviour(dataStoreDef, this);
203
+ dataStoreRefs.set(dataStoreDef.id, dataStore);
188
204
 
189
205
  return dataStore;
190
206
  };
@@ -14,9 +14,6 @@ function Formatter(element, formatQ) {
14
14
  this.broker = broker;
15
15
  this.logger = logger;
16
16
  this.formatQ = formatQ;
17
-
18
- this.pendingFormats = [];
19
-
20
17
  this[kOnMessage] = this._onMessage.bind(this);
21
18
  }
22
19
 
package/src/Timers.js CHANGED
@@ -10,14 +10,14 @@ export function Timers(options) {
10
10
  clearTimeout,
11
11
  ...options,
12
12
  };
13
- this[kExecuting] = [];
13
+ this[kExecuting] = new Set();
14
14
  this.setTimeout = this.setTimeout.bind(this);
15
15
  this.clearTimeout = this.clearTimeout.bind(this);
16
16
  }
17
17
 
18
18
  Object.defineProperty(Timers.prototype, 'executing', {
19
19
  get() {
20
- return this[kExecuting].slice();
20
+ return [...this[kExecuting]];
21
21
  },
22
22
  });
23
23
 
@@ -30,10 +30,7 @@ Timers.prototype.setTimeout = function wrappedSetTimeout(callback, delay, ...arg
30
30
  };
31
31
 
32
32
  Timers.prototype.clearTimeout = function wrappedClearTimeout(ref) {
33
- const executing = this[kExecuting];
34
- const idx = executing.indexOf(ref);
35
- if (idx > -1) {
36
- executing.splice(idx, 1);
33
+ if (this[kExecuting].delete(ref)) {
37
34
  ref.timerRef = this.options.clearTimeout(ref.timerRef);
38
35
  return;
39
36
  }
@@ -43,15 +40,14 @@ Timers.prototype.clearTimeout = function wrappedClearTimeout(ref) {
43
40
  Timers.prototype._setTimeout = function setTimeout(owner, callback, delay, ...args) {
44
41
  const executing = this[kExecuting];
45
42
  const ref = this._getReference(owner, callback, delay, args);
46
- executing.push(ref);
43
+ executing.add(ref);
47
44
  if (delay < MAX_DELAY) {
48
45
  ref.timerRef = this.options.setTimeout(onTimeout, ref.delay, ...ref.args);
49
46
  }
50
47
  return ref;
51
48
 
52
49
  function onTimeout(...rargs) {
53
- const idx = executing.indexOf(ref);
54
- if (idx > -1) executing.splice(idx, 1);
50
+ executing.delete(ref);
55
51
  return callback(...rargs);
56
52
  }
57
53
  };
package/src/Tracker.js CHANGED
@@ -1,14 +1,14 @@
1
1
  export function ActivityTracker(parentId) {
2
2
  this.id = parentId;
3
- this.status = { wait: [], execute: [], timer: [] };
3
+ this.status = { wait: new Set(), execute: new Set(), timer: new Set() };
4
4
  }
5
5
 
6
6
  Object.defineProperty(ActivityTracker.prototype, 'activityStatus', {
7
7
  get() {
8
8
  const status = this.status;
9
- if (status.execute.length) return 'executing';
10
- if (status.timer.length) return 'timer';
11
- return status.wait.length ? 'wait' : 'idle';
9
+ if (status.execute.size) return 'executing';
10
+ if (status.timer.size) return 'timer';
11
+ return status.wait.size ? 'wait' : 'idle';
12
12
  },
13
13
  });
14
14
 
@@ -46,29 +46,25 @@ ActivityTracker.prototype.track = function track(routingKey, message) {
46
46
 
47
47
  ActivityTracker.prototype._executing = function executing(id) {
48
48
  const { wait, execute } = this.status;
49
- if (execute.indexOf(id) === -1) execute.push(id);
50
- let idx;
51
- if ((idx = wait.indexOf(id)) !== -1) wait.splice(idx, 1);
49
+ wait.delete(id);
50
+ execute.add(id);
52
51
  };
53
52
 
54
53
  ActivityTracker.prototype._waiting = function waiting(id) {
55
54
  const { wait, execute } = this.status;
56
- if (wait.indexOf(id) === -1) wait.push(id);
57
- let idx;
58
- if ((idx = execute.indexOf(id)) !== -1) execute.splice(idx, 1);
55
+ execute.delete(id);
56
+ wait.add(id);
59
57
  };
60
58
 
61
59
  ActivityTracker.prototype._timer = function timerFn(id) {
62
60
  const { timer, execute } = this.status;
63
- if (timer.indexOf(id) === -1) timer.push(id);
64
- let idx;
65
- if ((idx = execute.indexOf(id)) !== -1) execute.splice(idx, 1);
61
+ execute.delete(id);
62
+ timer.add(id);
66
63
  };
67
64
 
68
65
  ActivityTracker.prototype._leave = function leave(id) {
69
66
  const { wait, execute, timer } = this.status;
70
- let idx;
71
- if ((idx = wait.indexOf(id)) !== -1) wait.splice(idx, 1);
72
- if ((idx = execute.indexOf(id)) !== -1) execute.splice(idx, 1);
73
- if ((idx = timer.indexOf(id)) !== -1) timer.splice(idx, 1);
67
+ execute.delete(id);
68
+ timer.delete(id);
69
+ wait.delete(id);
74
70
  };
@@ -347,11 +347,13 @@ Activity.prototype.addInboundListeners = function addInboundListeners() {
347
347
  const onInboundEvent = this._onInboundEvent.bind(this);
348
348
  const triggerConsumerTag = `_inbound-${this.id}`;
349
349
  for (const trigger of this[kFlows].inboundTriggers) {
350
- if (trigger.isSequenceFlow)
350
+ if (trigger.isSequenceFlow) {
351
351
  trigger.broker.subscribeTmp('event', 'flow.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
352
- else if (this.isForCompensation)
352
+ } else if (this.isForCompensation) {
353
353
  trigger.broker.subscribeTmp('event', 'association.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
354
- else trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
354
+ } else {
355
+ trigger.broker.subscribeTmp('event', 'activity.#', onInboundEvent, { noAck: true, consumerTag: triggerConsumerTag });
356
+ }
355
357
  }
356
358
  };
357
359
 
@@ -14,7 +14,7 @@ function ActivityExecution(activity, context) {
14
14
  this.context = context;
15
15
  this.id = activity.id;
16
16
  this.broker = activity.broker;
17
- this[kPostponed] = [];
17
+ this[kPostponed] = new Set();
18
18
  this[kCompleted] = false;
19
19
  this[kExecuteQ] = this.broker.assertQueue('execute-q', { durable: true, autoDelete: false });
20
20
 
@@ -43,7 +43,7 @@ ActivityExecution.prototype.execute = function execute(executeMessage) {
43
43
  }));
44
44
 
45
45
  if (executeMessage.fields.redelivered) {
46
- this[kPostponed].splice(0);
46
+ this[kPostponed].clear();
47
47
  this._debug('resume execution');
48
48
 
49
49
  if (!this.source) this.source = new this.activity.Behaviour(this.activity, this.context);
@@ -108,11 +108,12 @@ ActivityExecution.prototype.getApi = function getApi(apiMessage) {
108
108
  const api = ActivityApi(self.broker, apiMessage);
109
109
 
110
110
  api.getExecuting = function getExecuting() {
111
- return self[kPostponed].reduce((result, msg) => {
112
- if (msg.content.executionId === apiMessage.content.executionId) return result;
111
+ const result = [];
112
+ for (const msg of self[kPostponed]) {
113
+ if (msg.content.executionId === apiMessage.content.executionId) continue;
113
114
  result.push(self.getApi(msg));
114
- return result;
115
- }, []);
115
+ }
116
+ return result;
116
117
  };
117
118
 
118
119
  return api;
@@ -124,7 +125,10 @@ ActivityExecution.prototype.passthrough = function passthrough(executeMessage) {
124
125
  };
125
126
 
126
127
  ActivityExecution.prototype.getPostponed = function getPostponed() {
127
- let apis = this[kPostponed].map((msg) => this.getApi(msg));
128
+ let apis = [];
129
+ for (const msg of this[kPostponed]) {
130
+ apis.push(this.getApi(msg));
131
+ }
128
132
  if (!this.activity.isSubProcess || !this.source) return apis;
129
133
  apis = apis.concat(this.source.getPostponed());
130
134
  return apis;
@@ -139,7 +143,7 @@ ActivityExecution.prototype.getState = function getState() {
139
143
  };
140
144
 
141
145
  ActivityExecution.prototype.recover = function recover(state) {
142
- this[kPostponed].splice(0);
146
+ this[kPostponed].clear();
143
147
 
144
148
  if (!state) return this;
145
149
  if ('completed' in state) this[kCompleted] = state.completed;
@@ -174,7 +178,7 @@ ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routin
174
178
 
175
179
  switch (routingKey) {
176
180
  case 'execute.resume.execution': {
177
- if (!this[kPostponed].length) return this.broker.publish('execution', 'execute.start', cloneContent(this[kExecuteMessage].content));
181
+ if (!this[kPostponed].size) return this.broker.publish('execution', 'execute.start', cloneContent(this[kExecuteMessage].content));
178
182
  break;
179
183
  }
180
184
  case 'execute.cancel':
@@ -215,22 +219,27 @@ ActivityExecution.prototype._onExecuteMessage = function onExecuteMessage(routin
215
219
  ActivityExecution.prototype._onStateChangeMessage = function onStateChangeMessage(message) {
216
220
  const { ignoreIfExecuting, executionId } = message.content;
217
221
  const postponed = this[kPostponed];
218
- const idx = postponed.findIndex((msg) => msg.content.executionId === executionId);
222
+
219
223
  let previousMsg;
220
- if (idx > -1) {
224
+ for (const msg of postponed) {
225
+ if (msg.content.executionId === executionId) previousMsg = msg;
226
+ }
227
+
228
+ if (previousMsg) {
221
229
  if (ignoreIfExecuting) {
222
230
  message.ack();
223
231
  return false;
224
232
  }
225
233
 
226
- previousMsg = postponed.splice(idx, 1, message)[0];
234
+ postponed.delete(previousMsg);
235
+ postponed.add(message);
227
236
  previousMsg.ack();
228
237
 
238
+ return true;
239
+ } else {
240
+ postponed.add(message);
229
241
  return true;
230
242
  }
231
-
232
- postponed.push(message);
233
- return true;
234
243
  };
235
244
 
236
245
  ActivityExecution.prototype._onExecutionCompleted = function onExecutionCompleted(message) {
@@ -242,8 +251,11 @@ ActivityExecution.prototype._onExecutionCompleted = function onExecutionComplete
242
251
  if (!isRootScope) {
243
252
  this._debug('completed sub execution');
244
253
  if (!keep) message.ack();
245
- if (postponed.length === 1 && postponed[0].content.isRootScope && !postponed[0].content.preventComplete) {
246
- return this.broker.publish('execution', 'execute.completed', cloneContent(postponed[0].content));
254
+ if (postponed.size === 1) {
255
+ const onlyMessage = postponed.values().next().value;
256
+ if (onlyMessage.content.isRootScope && !onlyMessage.content.preventComplete) {
257
+ return this.broker.publish('execution', 'execute.completed', cloneContent(onlyMessage.content));
258
+ }
247
259
  }
248
260
  return;
249
261
  }
@@ -256,7 +268,7 @@ ActivityExecution.prototype._onExecutionCompleted = function onExecutionComplete
256
268
  this.deactivate();
257
269
 
258
270
  const subApis = this.getPostponed();
259
- postponed.splice(0);
271
+ postponed.clear();
260
272
  for (const api of subApis) api.discard();
261
273
 
262
274
  this._publishExecutionCompleted('completed', { ...postponedMsg.content, ...message.content }, message.properties.correlationId);
@@ -271,8 +283,11 @@ ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarde
271
283
  const correlationId = message.properties.correlationId;
272
284
  if (!error && !isRootScope) {
273
285
  message.ack();
274
- if (postponed.length === 1 && postponed[0].content.isRootScope) {
275
- return this.broker.publish('execution', 'execute.discard', postponed[0].content, { correlationId });
286
+ if (postponed.size === 1) {
287
+ const onlyMessage = postponed.values().next().value;
288
+ if (onlyMessage.content.isRootScope) {
289
+ return this.broker.publish('execution', 'execute.discard', onlyMessage.content, { correlationId });
290
+ }
276
291
  }
277
292
  return;
278
293
  }
@@ -282,7 +297,7 @@ ActivityExecution.prototype._onExecutionDiscarded = function onExecutionDiscarde
282
297
  this.deactivate();
283
298
 
284
299
  const subApis = this.getPostponed();
285
- postponed.splice(0);
300
+ postponed.clear();
286
301
  for (const api of subApis) api.discard();
287
302
 
288
303
  this._publishExecutionCompleted(discardType, cloneContent(message.content), correlationId);
@@ -310,11 +325,13 @@ ActivityExecution.prototype._ackPostponed = function ackPostponed(completeMessag
310
325
  const { executionId: eid } = completeMessage.content;
311
326
 
312
327
  const postponed = this[kPostponed];
313
- const idx = postponed.findIndex(({ content: c }) => c.executionId === eid);
314
- if (idx === -1) return;
315
- const [msg] = postponed.splice(idx, 1);
316
- msg.ack();
317
- return msg;
328
+ for (const msg of postponed) {
329
+ if (msg.content.executionId === eid) {
330
+ postponed.delete(msg);
331
+ msg.ack();
332
+ return msg;
333
+ }
334
+ }
318
335
  };
319
336
 
320
337
  ActivityExecution.prototype._onParentApiMessage = function onParentApiMessage(routingKey, message) {