@5minds/node-red-contrib-processcube 1.5.4-develop-5e0b5a-m36zyoaj → 1.5.5-develop-9244da-m3hs2wpp

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.
@@ -13,29 +13,37 @@ module.exports = function (RED) {
13
13
  }
14
14
 
15
15
  let currentIdentity = node.engine.identity;
16
- let subscription = await client.events.onEndEventFinished(
17
- (endEventFinished) => {
18
- node.send({
19
- payload: endEventFinished,
20
- });
21
- },
22
- { identity: currentIdentity },
23
- );
24
-
25
- node.engine.registerOnIdentityChanged(async (identity) => {
26
- client.events.removeSubscription(subscription, currentIdentity);
27
-
28
- currentIdentity = identity;
29
16
 
17
+ let subscription = null;
18
+
19
+ try {
30
20
  subscription = await client.events.onEndEventFinished(
31
21
  (endEventFinished) => {
32
22
  node.send({
33
- payload: endEventFinished
23
+ payload: endEventFinished,
34
24
  });
35
25
  },
36
26
  { identity: currentIdentity },
37
27
  );
38
- });
28
+
29
+ node.engine.registerOnIdentityChanged(async (identity) => {
30
+ client.events.removeSubscription(subscription, currentIdentity);
31
+
32
+ currentIdentity = identity;
33
+
34
+ subscription = await client.events.onEndEventFinished(
35
+ (endEventFinished) => {
36
+ node.send({
37
+ payload: endEventFinished
38
+ });
39
+ },
40
+ { identity: currentIdentity },
41
+ );
42
+ });
43
+
44
+ } catch (error) {
45
+ node.error(error);
46
+ }
39
47
 
40
48
  node.on('close', async () => {
41
49
  if (node.engine && node.engine.engineClient && client) {
@@ -241,7 +241,7 @@
241
241
  "fc23f271b106648f"
242
242
  ],
243
243
  "x": 34,
244
- "y": 259,
244
+ "y": 239,
245
245
  "w": 652,
246
246
  "h": 202
247
247
  },
@@ -467,6 +467,30 @@
467
467
  "w": 572,
468
468
  "h": 142
469
469
  },
470
+ {
471
+ "id": "3f3c01daebb2d215",
472
+ "type": "group",
473
+ "z": "fd3c725340de4f74",
474
+ "style": {
475
+ "stroke": "#999999",
476
+ "stroke-opacity": "1",
477
+ "fill": "none",
478
+ "fill-opacity": "1",
479
+ "label": true,
480
+ "label-position": "nw",
481
+ "color": "#a4a4a4"
482
+ },
483
+ "nodes": [
484
+ "2fadb4c4667ecaf2",
485
+ "93331783b7ef3fc5",
486
+ "bc26f9821540f097",
487
+ "cc3fb9c2cb0edd3a"
488
+ ],
489
+ "x": 34,
490
+ "y": 459,
491
+ "w": 552,
492
+ "h": 142
493
+ },
470
494
  {
471
495
  "id": "42e6796dddd9d4db",
472
496
  "type": "processcube-engine-config",
@@ -487,6 +511,8 @@
487
511
  "name": "Test",
488
512
  "engine": "42e6796dddd9d4db",
489
513
  "topic": "Test",
514
+ "workerConfig": "{}",
515
+ "workerConfigType": "json",
490
516
  "x": 110,
491
517
  "y": 180,
492
518
  "wires": [
@@ -539,6 +565,8 @@
539
565
  "name": "SampleError",
540
566
  "engine": "42e6796dddd9d4db",
541
567
  "topic": "SampleError",
568
+ "workerConfig": "{}",
569
+ "workerConfigType": "json",
542
570
  "x": 130,
543
571
  "y": 360,
544
572
  "wires": [
@@ -798,6 +826,8 @@
798
826
  "name": "Test_Auth",
799
827
  "engine": "b78932d162d8d468",
800
828
  "topic": "Test_Auth",
829
+ "workerConfig": "{}",
830
+ "workerConfigType": "json",
801
831
  "x": 120,
802
832
  "y": 180,
803
833
  "wires": [
@@ -861,6 +891,8 @@
861
891
  "name": "SampleError_Auth",
862
892
  "engine": "b78932d162d8d468",
863
893
  "topic": "SampleError_Auth",
894
+ "workerConfig": "{}",
895
+ "workerConfigType": "json",
864
896
  "x": 150,
865
897
  "y": 360,
866
898
  "wires": [
@@ -1120,7 +1152,7 @@
1120
1152
  "query": "payload",
1121
1153
  "query_type": "msg",
1122
1154
  "x": 180,
1123
- "y": 420,
1155
+ "y": 400,
1124
1156
  "wires": [
1125
1157
  [
1126
1158
  "8ef39e83173d41e3"
@@ -1141,7 +1173,7 @@
1141
1173
  "finalize": "",
1142
1174
  "libs": [],
1143
1175
  "x": 390,
1144
- "y": 420,
1176
+ "y": 400,
1145
1177
  "wires": [
1146
1178
  [
1147
1179
  "f524b8cc35d56849"
@@ -1158,7 +1190,7 @@
1158
1190
  "result": "payload.result",
1159
1191
  "result_type": "msg",
1160
1192
  "x": 580,
1161
- "y": 420,
1193
+ "y": 400,
1162
1194
  "wires": [
1163
1195
  []
1164
1196
  ]
@@ -1171,7 +1203,7 @@
1171
1203
  "name": "Demo to listen on a new usertask an finish them",
1172
1204
  "info": "",
1173
1205
  "x": 240,
1174
- "y": 300,
1206
+ "y": 280,
1175
1207
  "wires": []
1176
1208
  },
1177
1209
  {
@@ -1186,7 +1218,7 @@
1186
1218
  "query": "{}",
1187
1219
  "query_type": "json",
1188
1220
  "x": 160,
1189
- "y": 360,
1221
+ "y": 340,
1190
1222
  "wires": [
1191
1223
  [
1192
1224
  "f7c7682e3a6adaaa"
@@ -1231,6 +1263,72 @@
1231
1263
  ]
1232
1264
  ]
1233
1265
  },
1266
+ {
1267
+ "id": "2fadb4c4667ecaf2",
1268
+ "type": "usertask-input",
1269
+ "z": "fd3c725340de4f74",
1270
+ "g": "3f3c01daebb2d215",
1271
+ "name": "",
1272
+ "engine": "42e6796dddd9d4db",
1273
+ "query": "{\"flowNodeId\":\"gibt_es_nicht\"}",
1274
+ "query_type": "json",
1275
+ "sendtype": "array",
1276
+ "x": 300,
1277
+ "y": 560,
1278
+ "wires": [
1279
+ [
1280
+ "bc26f9821540f097"
1281
+ ]
1282
+ ]
1283
+ },
1284
+ {
1285
+ "id": "93331783b7ef3fc5",
1286
+ "type": "inject",
1287
+ "z": "fd3c725340de4f74",
1288
+ "g": "3f3c01daebb2d215",
1289
+ "name": "",
1290
+ "props": [],
1291
+ "repeat": "",
1292
+ "crontab": "",
1293
+ "once": false,
1294
+ "onceDelay": 0.1,
1295
+ "topic": "",
1296
+ "x": 130,
1297
+ "y": 560,
1298
+ "wires": [
1299
+ [
1300
+ "2fadb4c4667ecaf2"
1301
+ ]
1302
+ ]
1303
+ },
1304
+ {
1305
+ "id": "bc26f9821540f097",
1306
+ "type": "debug",
1307
+ "z": "fd3c725340de4f74",
1308
+ "g": "3f3c01daebb2d215",
1309
+ "name": "debug 34",
1310
+ "active": true,
1311
+ "tosidebar": true,
1312
+ "console": false,
1313
+ "tostatus": false,
1314
+ "complete": "false",
1315
+ "statusVal": "",
1316
+ "statusType": "auto",
1317
+ "x": 480,
1318
+ "y": 560,
1319
+ "wires": []
1320
+ },
1321
+ {
1322
+ "id": "cc3fb9c2cb0edd3a",
1323
+ "type": "comment",
1324
+ "z": "fd3c725340de4f74",
1325
+ "g": "3f3c01daebb2d215",
1326
+ "name": "Search UserTasks",
1327
+ "info": "",
1328
+ "x": 150,
1329
+ "y": 500,
1330
+ "wires": []
1331
+ },
1234
1332
  {
1235
1333
  "id": "c4f20aefe585bdad",
1236
1334
  "type": "comment",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube",
3
- "version": "1.5.4-develop-5e0b5a-m36zyoaj",
3
+ "version": "1.5.5-develop-9244da-m3hs2wpp",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for ProcessCube",
6
6
  "scripts": {
@@ -24,33 +24,38 @@ module.exports = function (RED) {
24
24
  async (processNotification) => {
25
25
  if (
26
26
  config.processmodel != '' &&
27
- config.processmodel != processNotification.processModelId
28
- )
27
+ config.processmodel != processNotification.processModelId) {
29
28
  return;
29
+ }
30
+
30
31
  const newQuery = {
31
32
  processInstanceId: processNotification.processInstanceId,
32
33
  ...query,
33
34
  };
34
35
 
35
- const matchingInstances = await client.processInstances.query(newQuery, {
36
- identity: currentIdentity,
37
- });
38
-
39
- if (
40
- matchingInstances.processInstances &&
41
- matchingInstances.processInstances.length == 1
42
- ) {
43
- const processInstance = matchingInstances.processInstances[0];
44
-
45
- node.send({
46
- payload: {
47
- processInstanceId: processNotification.processInstanceId,
48
- processModelId: processNotification.processModelId,
49
- processInstance: processInstance,
50
- action: 'starting',
51
- type: 'processInstance',
52
- },
36
+ try {
37
+ const matchingInstances = await client.processInstances.query(newQuery, {
38
+ identity: currentIdentity,
53
39
  });
40
+
41
+ if (
42
+ matchingInstances.processInstances &&
43
+ matchingInstances.processInstances.length == 1
44
+ ) {
45
+ const processInstance = matchingInstances.processInstances[0];
46
+
47
+ node.send({
48
+ payload: {
49
+ processInstanceId: processNotification.processInstanceId,
50
+ processModelId: processNotification.processModelId,
51
+ processInstance: processInstance,
52
+ action: 'starting',
53
+ type: 'processInstance',
54
+ },
55
+ });
56
+ }
57
+ } catch (error) {
58
+ node.error(error);
54
59
  }
55
60
  },
56
61
  { identity: currentIdentity }
@@ -60,34 +65,39 @@ module.exports = function (RED) {
60
65
  async (processNotification) => {
61
66
  if (
62
67
  config.processmodel != '' &&
63
- config.processmodel != processNotification.processModelId
64
- )
68
+ config.processmodel != processNotification.processModelId) {
65
69
  return;
70
+ }
71
+
66
72
  const newQuery = {
67
73
  processInstanceId: processNotification.processInstanceId,
68
74
  ...query,
69
75
  };
70
76
 
71
- const matchingInstances = await client.processInstances.query(newQuery, {
72
- identity: currentIdentity,
73
- });
74
-
75
- if (
76
- matchingInstances.processInstances &&
77
- matchingInstances.processInstances.length == 1
78
- ) {
79
- const processInstance = matchingInstances.processInstances[0];
80
- node.send({
81
- payload: {
82
- processInstanceId: processNotification.processInstanceId,
83
- processModelId: processNotification.processModelId,
84
- flowNodeId: processNotification.flowNodeId,
85
- token: processNotification.currentToken,
86
- processInstance: processInstance,
87
- action: 'started',
88
- type: 'processInstance',
89
- },
77
+ try {
78
+ const matchingInstances = await client.processInstances.query(newQuery, {
79
+ identity: currentIdentity,
90
80
  });
81
+
82
+ if (
83
+ matchingInstances.processInstances &&
84
+ matchingInstances.processInstances.length == 1
85
+ ) {
86
+ const processInstance = matchingInstances.processInstances[0];
87
+ node.send({
88
+ payload: {
89
+ processInstanceId: processNotification.processInstanceId,
90
+ processModelId: processNotification.processModelId,
91
+ flowNodeId: processNotification.flowNodeId,
92
+ token: processNotification.currentToken,
93
+ processInstance: processInstance,
94
+ action: 'started',
95
+ type: 'processInstance',
96
+ },
97
+ });
98
+ }
99
+ } catch (error) {
100
+ node.error(error);
91
101
  }
92
102
  },
93
103
  { identity: currentIdentity }
@@ -106,25 +116,29 @@ module.exports = function (RED) {
106
116
  ...query,
107
117
  };
108
118
 
109
- const matchingInstances = await client.processInstances.query(newQuery, {
110
- identity: currentIdentity,
111
- });
112
-
113
- if (
114
- matchingInstances.processInstances &&
115
- matchingInstances.processInstances.length == 1
116
- ) {
117
- const processInstance = matchingInstances.processInstances[0];
118
- node.send({
119
- payload: {
120
- processInstanceId: processNotification.processInstanceId,
121
- processModelId: processNotification.processModelId,
122
- token: processNotification.currentToken,
123
- processInstance: processInstance,
124
- action: 'resumed',
125
- type: 'processInstance',
126
- },
119
+ try {
120
+ const matchingInstances = await client.processInstances.query(newQuery, {
121
+ identity: currentIdentity,
127
122
  });
123
+
124
+ if (
125
+ matchingInstances.processInstances &&
126
+ matchingInstances.processInstances.length == 1
127
+ ) {
128
+ const processInstance = matchingInstances.processInstances[0];
129
+ node.send({
130
+ payload: {
131
+ processInstanceId: processNotification.processInstanceId,
132
+ processModelId: processNotification.processModelId,
133
+ token: processNotification.currentToken,
134
+ processInstance: processInstance,
135
+ action: 'resumed',
136
+ type: 'processInstance',
137
+ },
138
+ });
139
+ }
140
+ } catch (error) {
141
+ node.error(error);
128
142
  }
129
143
  },
130
144
  { identity: currentIdentity }
@@ -143,26 +157,30 @@ module.exports = function (RED) {
143
157
  ...query,
144
158
  };
145
159
 
146
- const matchingInstances = await client.processInstances.query(newQuery, {
147
- identity: currentIdentity,
148
- });
149
-
150
- if (
151
- matchingInstances.processInstances &&
152
- matchingInstances.processInstances.length == 1
153
- ) {
154
- const processInstance = matchingInstances.processInstances[0];
155
- node.send({
156
- payload: {
157
- processInstanceId: processNotification.processInstanceId,
158
- processModelId: processNotification.processModelId,
159
- flowNodeId: processNotification.flowNodeId,
160
- token: processNotification.currentToken,
161
- processInstance: processInstance,
162
- action: 'finished',
163
- type: 'processInstance',
164
- },
160
+ try {
161
+ const matchingInstances = await client.processInstances.query(newQuery, {
162
+ identity: currentIdentity,
165
163
  });
164
+
165
+ if (
166
+ matchingInstances.processInstances &&
167
+ matchingInstances.processInstances.length == 1
168
+ ) {
169
+ const processInstance = matchingInstances.processInstances[0];
170
+ node.send({
171
+ payload: {
172
+ processInstanceId: processNotification.processInstanceId,
173
+ processModelId: processNotification.processModelId,
174
+ flowNodeId: processNotification.flowNodeId,
175
+ token: processNotification.currentToken,
176
+ processInstance: processInstance,
177
+ action: 'finished',
178
+ type: 'processInstance',
179
+ },
180
+ });
181
+ }
182
+ } catch (error) {
183
+ node.error(error);
166
184
  }
167
185
  },
168
186
  { identity: currentIdentity }
@@ -181,25 +199,28 @@ module.exports = function (RED) {
181
199
  ...query,
182
200
  };
183
201
 
184
- const matchingInstances = await client.processInstances.query(newQuery, {
185
- identity: currentIdentity,
186
- });
187
-
188
- if (
189
- matchingInstances.processInstances &&
190
- matchingInstances.processInstances.length == 1
191
- ) {
192
- const processInstance = matchingInstances.processInstances[0];
193
- node.send({
194
- payload: {
195
- processInstanceId: processNotification.processInstanceId,
196
- processModelId: processNotification.processModelId,
197
- token: processNotification.currentToken,
198
- processInstance: processInstance,
199
- action: 'terminated',
200
- type: 'processInstance',
201
- },
202
+ try {
203
+ const matchingInstances = await client.processInstances.query(newQuery, {
204
+ identity: currentIdentity,
202
205
  });
206
+ if (
207
+ matchingInstances.processInstances &&
208
+ matchingInstances.processInstances.length == 1
209
+ ) {
210
+ const processInstance = matchingInstances.processInstances[0];
211
+ node.send({
212
+ payload: {
213
+ processInstanceId: processNotification.processInstanceId,
214
+ processModelId: processNotification.processModelId,
215
+ token: processNotification.currentToken,
216
+ processInstance: processInstance,
217
+ action: 'terminated',
218
+ type: 'processInstance',
219
+ },
220
+ });
221
+ }
222
+ } catch (error) {
223
+ node.error(error);
203
224
  }
204
225
  },
205
226
  { identity: currentIdentity }
@@ -218,25 +239,29 @@ module.exports = function (RED) {
218
239
  ...query,
219
240
  };
220
241
 
221
- const matchingInstances = await client.processInstances.query(newQuery, {
222
- identity: currentIdentity,
223
- });
224
-
225
- if (
226
- matchingInstances.processInstances &&
227
- matchingInstances.processInstances.length == 1
228
- ) {
229
- const processInstance = matchingInstances.processInstances[0];
230
- node.send({
231
- payload: {
232
- processInstanceId: processNotification.processInstanceId,
233
- processModelId: processNotification.processModelId,
234
- token: processNotification.currentToken,
235
- processInstance: processInstance,
236
- action: 'error',
237
- type: 'processInstance',
238
- },
242
+ try {
243
+ const matchingInstances = await client.processInstances.query(newQuery, {
244
+ identity: currentIdentity,
239
245
  });
246
+
247
+ if (
248
+ matchingInstances.processInstances &&
249
+ matchingInstances.processInstances.length == 1
250
+ ) {
251
+ const processInstance = matchingInstances.processInstances[0];
252
+ node.send({
253
+ payload: {
254
+ processInstanceId: processNotification.processInstanceId,
255
+ processModelId: processNotification.processModelId,
256
+ token: processNotification.currentToken,
257
+ processInstance: processInstance,
258
+ action: 'error',
259
+ type: 'processInstance',
260
+ },
261
+ });
262
+ }
263
+ } catch (error) {
264
+ node.error(error);
240
265
  }
241
266
  },
242
267
  { identity: currentIdentity }
@@ -255,24 +280,28 @@ module.exports = function (RED) {
255
280
  ...query,
256
281
  };
257
282
 
258
- const matchingInstances = await client.processInstances.query(newQuery, {
259
- identity: currentIdentity,
260
- });
261
-
262
- if (
263
- matchingInstances.processInstances &&
264
- matchingInstances.processInstances.length == 1
265
- ) {
266
- const processInstance = matchingInstances.processInstances[0];
267
- node.send({
268
- payload: {
269
- processInstanceId: processNotification.processInstanceId,
270
- processModelId: processNotification.processModelId,
271
- processInstance: processInstance,
272
- action: 'owner-changed',
273
- type: 'processInstance',
274
- },
283
+ try {
284
+ const matchingInstances = await client.processInstances.query(newQuery, {
285
+ identity: currentIdentity,
275
286
  });
287
+
288
+ if (
289
+ matchingInstances.processInstances &&
290
+ matchingInstances.processInstances.length == 1
291
+ ) {
292
+ const processInstance = matchingInstances.processInstances[0];
293
+ node.send({
294
+ payload: {
295
+ processInstanceId: processNotification.processInstanceId,
296
+ processModelId: processNotification.processModelId,
297
+ processInstance: processInstance,
298
+ action: 'owner-changed',
299
+ type: 'processInstance',
300
+ },
301
+ });
302
+ }
303
+ } catch (error) {
304
+ node.error(error);
276
305
  }
277
306
  },
278
307
  { identity: currentIdentity }
@@ -291,24 +320,28 @@ module.exports = function (RED) {
291
320
  ...query,
292
321
  };
293
322
 
294
- const matchingInstances = await client.processInstances.query(newQuery, {
295
- identity: currentIdentity,
296
- });
297
-
298
- if (
299
- matchingInstances.processInstances &&
300
- matchingInstances.processInstances.length == 1
301
- ) {
302
- const processInstance = matchingInstances.processInstances[0];
303
- node.send({
304
- payload: {
305
- processInstanceId: processNotification.processInstanceId,
306
- processModelId: processNotification.processModelId,
307
- processInstance: processInstance,
308
- action: 'instances-deleted',
309
- type: 'processInstance',
310
- },
323
+ try {
324
+ const matchingInstances = await client.processInstances.query(newQuery, {
325
+ identity: currentIdentity,
311
326
  });
327
+
328
+ if (
329
+ matchingInstances.processInstances &&
330
+ matchingInstances.processInstances.length == 1
331
+ ) {
332
+ const processInstance = matchingInstances.processInstances[0];
333
+ node.send({
334
+ payload: {
335
+ processInstanceId: processNotification.processInstanceId,
336
+ processModelId: processNotification.processModelId,
337
+ processInstance: processInstance,
338
+ action: 'instances-deleted',
339
+ type: 'processInstance',
340
+ },
341
+ });
342
+ }
343
+ } catch (error) {
344
+ node.error(error);
312
345
  }
313
346
  },
314
347
  { identity: currentIdentity }
@@ -400,6 +433,7 @@ module.exports = function (RED) {
400
433
  },
401
434
  { identity: currentIdentity }
402
435
  );
436
+
403
437
  });
404
438
 
405
439
  node.on('close', () => {
@@ -17,9 +17,11 @@ module.exports = function (RED) {
17
17
 
18
18
  query = {
19
19
  ...query,
20
- identity: engine.identity,
20
+ identity: undefined,
21
21
  };
22
22
 
23
+ node.log(`Querying process definitions with query: ${JSON.stringify(query)}`);
24
+
23
25
  client.processDefinitions.getAll(query).then((matchingProcessDefinitions) => {
24
26
 
25
27
  if (config.models_only && matchingProcessDefinitions.totalCount > 0) {
@@ -40,6 +42,8 @@ module.exports = function (RED) {
40
42
  }
41
43
 
42
44
  node.send(msg);
45
+ }).catch((error) => {
46
+ node.error(error);
43
47
  });
44
48
  });
45
49
  }
@@ -20,27 +20,32 @@ module.exports = function (RED) {
20
20
  function userTaskCallback() {
21
21
  return async (userTaskNotification) => {
22
22
  if (config.usertask != '' && config.usertask != userTaskNotification.flowNodeId) return;
23
+
23
24
  const newQuery = {
24
25
  flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
25
26
  ...query,
26
27
  };
27
28
 
28
- const matchingFlowNodes = await client.userTasks.query(newQuery, {
29
- identity: currentIdentity,
30
- });
29
+ try {
30
+ const matchingFlowNodes = await client.userTasks.query(newQuery, {
31
+ identity: currentIdentity,
32
+ });
31
33
 
32
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
33
- const userTask = matchingFlowNodes.userTasks[0];
34
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
35
+ const userTask = matchingFlowNodes.userTasks[0];
34
36
 
35
- node.send({
36
- payload: {
37
- flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
38
- userTaskEvent: userTaskNotification,
39
- userTask: userTask,
40
- action: config.eventtype,
41
- type: 'usertask',
42
- },
43
- });
37
+ node.send({
38
+ payload: {
39
+ flowNodeInstanceId: userTaskNotification.flowNodeInstanceId,
40
+ userTaskEvent: userTaskNotification,
41
+ userTask: userTask,
42
+ action: config.eventtype,
43
+ type: 'usertask',
44
+ },
45
+ });
46
+ }
47
+ } catch (error) {
48
+ node.error(error);
44
49
  }
45
50
  };
46
51
  }
@@ -79,7 +84,7 @@ module.exports = function (RED) {
79
84
  currentIdentity = identity;
80
85
 
81
86
  subscription = subscribe();
82
- });
87
+ })
83
88
 
84
89
  node.on('close', async () => {
85
90
  if (node.engine && node.engine.engineClient && client) {
@@ -27,23 +27,27 @@ module.exports = function (RED) {
27
27
  ...query
28
28
  };
29
29
 
30
- const matchingFlowNodes = await client.userTasks.query(newQuery, { identity: currentIdentity });
31
-
32
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
33
- // remove subscription
34
- client.userTasks.removeSubscription(subscription, currentIdentity);
35
-
36
- const userTask = matchingFlowNodes.userTasks[0];
37
-
38
- msg.payload = { userTask: userTask };
39
- node.send(msg);
40
- } else {
41
- // nothing todo - wait for next notification
30
+ try {
31
+ const matchingFlowNodes = await client.userTasks.query(newQuery, { identity: currentIdentity });
32
+
33
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length == 1) {
34
+ // remove subscription
35
+ client.userTasks.removeSubscription(subscription, currentIdentity);
36
+
37
+ const userTask = matchingFlowNodes.userTasks[0];
38
+
39
+ msg.payload = { userTask: userTask };
40
+ node.send(msg);
41
+ } else {
42
+ // nothing todo - wait for next notification
43
+ }
44
+ } catch (error) {
45
+ node.error(error);
42
46
  }
43
47
 
44
48
  }, { identity: currentIdentity });
45
49
 
46
- node.log({"Handling old userTasks config.only_for_new": config.only_for_new});
50
+ node.log({ "Handling old userTasks config.only_for_new": config.only_for_new });
47
51
 
48
52
  if (config.only_for_new === false) {
49
53
  // only check suspended user tasks
@@ -52,18 +56,22 @@ module.exports = function (RED) {
52
56
  ...query
53
57
  };
54
58
 
55
- const matchingFlowNodes = await client.userTasks.query(suspendedQuery, { identity: currentIdentity });
59
+ try {
60
+ const matchingFlowNodes = await client.userTasks.query(suspendedQuery, { identity: currentIdentity });
56
61
 
57
- if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
58
- const userTask = matchingFlowNodes.userTasks[0];
62
+ if (matchingFlowNodes.userTasks && matchingFlowNodes.userTasks.length >= 1) {
63
+ const userTask = matchingFlowNodes.userTasks[0];
59
64
 
60
- msg.payload = { userTask: userTask };
61
- node.send(msg);
65
+ msg.payload = { userTask: userTask };
66
+ node.send(msg);
62
67
 
63
- // remove subscription
64
- client.userTasks.removeSubscription(subscription, currentIdentity);
65
- } else {
66
- // let the *currentIdentity* be active
68
+ // remove subscription
69
+ client.userTasks.removeSubscription(subscription, currentIdentity);
70
+ } else {
71
+ // let the *currentIdentity* be active
72
+ }
73
+ } catch (error) {
74
+ node.error(error);
67
75
  }
68
76
  }
69
77
  };
@@ -84,7 +92,7 @@ module.exports = function (RED) {
84
92
 
85
93
  node.on("close", async () => {
86
94
  if (client != null && subscription != null) {
87
- client.userTasks.removeSubscription(subscription, currentIdentity);
95
+ client.userTasks.removeSubscription(subscription, currentIdentity);
88
96
  }
89
97
  });
90
98
  }