@node-red/nodes 5.0.0-beta.2 → 5.0.0-beta.3

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.
@@ -45,11 +45,11 @@ RED.debug = (function() {
45
45
  '<a id="red-ui-sidebar-debug-pause" class="red-ui-sidebar-header-button" href="#"><i class="fa fa-pause"></i></a>'+
46
46
  '</span>'+
47
47
  '<span class="button-group">'+
48
- '<a id="red-ui-sidebar-debug-filter" style="padding-right: 5px" class="red-ui-sidebar-header-button" href="#"><i class="fa fa-filter"></i> <span></span> <i style="padding-left: 5px;" class="fa fa-caret-down"></i></a>'+
48
+ '<a id="red-ui-sidebar-debug-filter" style="padding-right: 3px" class="red-ui-sidebar-header-button" href="#"><i class="fa fa-filter"></i> <span></span> <i style="padding-left: 5px;" class="fa fa-caret-down"></i></a>'+
49
49
  '</span>'+
50
50
  '<span class="button-group">'+
51
- '<a id="red-ui-sidebar-debug-clear" style="border-right: none; padding-right: 6px" class="red-ui-sidebar-header-button" href="#" data-clear-type="all"><i class="fa fa-trash"></i> <span>all</span></a>' +
52
- '<a id="red-ui-sidebar-debug-clear-opts" style="padding: 5px; border-left: none;" class="red-ui-sidebar-header-button" href="#"><i class="fa fa-caret-down"></i></a>'+
51
+ '<a id="red-ui-sidebar-debug-clear" style="border-right: none; padding-right: 2px" class="red-ui-sidebar-header-button" href="#" data-clear-type="all"><i class="fa fa-trash"></i> <span>all</span></a>' +
52
+ '<a id="red-ui-sidebar-debug-clear-opts" style="padding: 3px; border-left: none;" class="red-ui-sidebar-header-button" href="#"><i class="fa fa-caret-down"></i></a>'+
53
53
  '</span></div>').appendTo(content);
54
54
 
55
55
  var footerToolbar = $('<div>'+
@@ -433,12 +433,28 @@ RED.debug = (function() {
433
433
  if (o) { stack.push(o); }
434
434
  if (!busy && (stack.length > 0)) {
435
435
  busy = true;
436
- processDebugMessage(stack.shift());
437
- setTimeout(function() {
438
- busy = false;
439
- handleDebugMessage();
440
- }, 15); // every 15mS = 66 times a second
441
- if (stack.length > numMessages) { stack = stack.splice(-numMessages); }
436
+ const message = stack.shift()
437
+ // call any preDebugLog hooks, allowing them to modify the message or block it from being displayed
438
+ RED.hooks.trigger('debugPreProcessMessage', { message }).then(result => {
439
+ if (result === false) {
440
+ return false; // A hook returned false - halt processing of this message
441
+ }
442
+ return processDebugMessage(message);
443
+ }).then(processArtifacts => {
444
+ if (processArtifacts === false) {
445
+ return false; // A hook returned false - halt processing of this message
446
+ }
447
+ const { message, element, payload } = processArtifacts || {};
448
+ return RED.hooks.trigger('debugPostProcessMessage', { message, element, payload });
449
+ }).catch(err => {
450
+ console.error("Error in debug process message hooks", err);
451
+ }).finally(() => {
452
+ setTimeout(function() {
453
+ busy = false;
454
+ handleDebugMessage();
455
+ }, 15); // every 15mS = 66 times a second
456
+ if (stack.length > numMessages) { stack = stack.splice(-numMessages); }
457
+ })
442
458
  }
443
459
  } else {
444
460
  debugPausedMessageCount++
@@ -564,10 +580,13 @@ RED.debug = (function() {
564
580
  sourceId: sourceNode && sourceNode.id,
565
581
  rootPath: path,
566
582
  nodeSelector: config.messageSourceClick,
567
- enablePinning: true
583
+ enablePinning: true,
584
+ tools: o.tools // permit preDebugLog hooks to add extra tools to the <debugMessage> element
568
585
  });
569
586
  // Do this in a separate step so the element functions aren't stripped
570
587
  debugMessage.appendTo(el);
588
+ // add the meta row tools container, even if there are no tools, so that the postProcessDebugMessage hook can add tools
589
+ const tools = $('<span class="red-ui-debug-msg-tools button-group"></span>').appendTo(metaRow)
571
590
  // NOTE: relying on function error to have a "type" that all other msgs don't
572
591
  if (o.hasOwnProperty("type") && (o.type === "function")) {
573
592
  var errorLvlType = 'error';
@@ -579,7 +598,6 @@ RED.debug = (function() {
579
598
  msg.addClass('red-ui-debug-msg-level-' + errorLvl);
580
599
  $('<span class="red-ui-debug-msg-topic">function : (' + errorLvlType + ')</span>').appendTo(metaRow);
581
600
  } else {
582
- var tools = $('<span class="red-ui-debug-msg-tools button-group"></span>').appendTo(metaRow);
583
601
  var filterMessage = $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-caret-down"></i></button>').appendTo(tools);
584
602
  filterMessage.on("click", function(e) {
585
603
  e.preventDefault();
@@ -635,6 +653,14 @@ RED.debug = (function() {
635
653
  if (atBottom) {
636
654
  messageList.scrollTop(sbc.scrollHeight);
637
655
  }
656
+
657
+ // return artifacts to permit postProcessDebugMessage hooks to modify the message element, access the
658
+ // processed payload or otherwise modify the message after it has been generated.
659
+ return {
660
+ message: o, // original debug message object, useful for any hook that might have tagged additional info onto it
661
+ element: msg, // the top-level element for this debug message
662
+ payload // the reconstructed debug message
663
+ }
638
664
  }
639
665
 
640
666
  function clearMessageList(clearFilter, filteredOnly) {
@@ -164,7 +164,8 @@ module.exports = function(RED) {
164
164
  if (node.pauseType === "delay") {
165
165
  node.on("input", function(msg, send, done) {
166
166
  var id = ourTimeout(function() {
167
- node.idList.splice(node.idList.indexOf(id),1);
167
+ var idx = node.idList.indexOf(id);
168
+ if (idx !== -1) { node.idList.splice(idx, 1); }
168
169
  if (node.timeout > 1000) {
169
170
  node.status({fill:"blue",shape:"dot",text:node.idList.length});
170
171
  }
@@ -189,7 +190,8 @@ module.exports = function(RED) {
189
190
  }
190
191
  if (delayvar < 0) { delayvar = 0; }
191
192
  var id = ourTimeout(function() {
192
- node.idList.splice(node.idList.indexOf(id),1);
193
+ var idx = node.idList.indexOf(id);
194
+ if (idx !== -1) { node.idList.splice(idx, 1); }
193
195
  if (node.idList.length === 0) { node.status({}); }
194
196
  send(msg);
195
197
  if (delayvar >= 0) {
@@ -212,7 +214,8 @@ module.exports = function(RED) {
212
214
  node.on("input", function(msg, send, done) {
213
215
  var wait = node.randomFirst + (node.diff * Math.random());
214
216
  var id = ourTimeout(function() {
215
- node.idList.splice(node.idList.indexOf(id),1);
217
+ var idx = node.idList.indexOf(id);
218
+ if (idx !== -1) { node.idList.splice(idx, 1); }
216
219
  send(msg);
217
220
  if (node.timeout >= 1000) {
218
221
  node.status({fill:"blue",shape:"dot",text:node.idList.length});
@@ -105,18 +105,26 @@ module.exports = function(RED) {
105
105
  }
106
106
  node.activeProcesses[child.pid] = child;
107
107
  child.stdout.on('data', function (data) {
108
- if (node.activeProcesses.hasOwnProperty(child.pid) && node.activeProcesses[child.pid] !== null) {
109
- // console.log('[exec] stdout: ' + data,child.pid);
110
- if (isUtf8(data)) { msg.payload = data.toString(); }
111
- else { msg.payload = data; }
112
- nodeSend([RED.util.cloneMessage(msg),null,null]);
108
+ try {
109
+ if (node.activeProcesses.hasOwnProperty(child.pid) && node.activeProcesses[child.pid] !== null) {
110
+ // console.log('[exec] stdout: ' + data,child.pid);
111
+ if (isUtf8(data)) { msg.payload = data.toString(); }
112
+ else { msg.payload = data; }
113
+ nodeSend([RED.util.cloneMessage(msg),null,null]);
114
+ }
115
+ } catch (err) {
116
+ node.error(err.toString());
113
117
  }
114
118
  });
115
119
  child.stderr.on('data', function (data) {
116
- if (node.activeProcesses.hasOwnProperty(child.pid) && node.activeProcesses[child.pid] !== null) {
117
- if (isUtf8(data)) { msg.payload = data.toString(); }
118
- else { msg.payload = data; }
119
- nodeSend([null,RED.util.cloneMessage(msg),null]);
120
+ try {
121
+ if (node.activeProcesses.hasOwnProperty(child.pid) && node.activeProcesses[child.pid] !== null) {
122
+ if (isUtf8(data)) { msg.payload = data.toString(); }
123
+ else { msg.payload = data; }
124
+ nodeSend([null,RED.util.cloneMessage(msg),null]);
125
+ }
126
+ } catch (err) {
127
+ node.error(err.toString());
120
128
  }
121
129
  });
122
130
  child.on('close', function (code,signal) {
@@ -227,6 +227,7 @@ module.exports = function(RED) {
227
227
  * Handle the payload / packet recieved in MQTT In and MQTT Sub nodes
228
228
  */
229
229
  function subscriptionHandler(node, datatype ,topic, payload, packet) {
230
+ if (!packet) { packet = {}; }
230
231
  const msg = {topic:topic, payload:null, qos:packet.qos, retain:packet.retain};
231
232
  const v5 = (node && node.brokerConn)
232
233
  ? node.brokerConn.v5()
@@ -1074,12 +1075,16 @@ module.exports = function(RED) {
1074
1075
 
1075
1076
  if (!subscription.handler) {
1076
1077
  subscription.handler = function (mtopic, mpayload, mpacket) {
1077
- const sops = subscription.options ? subscription.options.properties : {}
1078
- const pops = mpacket.properties || {}
1079
- if (subIdsAvailable && pops.subscriptionIdentifier && sops.subscriptionIdentifier && (pops.subscriptionIdentifier !== sops.subscriptionIdentifier)) {
1080
- //do nothing as subscriptionIdentifier does not match
1081
- } else if (matchTopic(topic, mtopic)) {
1082
- subscription.callback && subscription.callback(mtopic, mpayload, mpacket)
1078
+ try {
1079
+ const sops = subscription.options ? subscription.options.properties : {}
1080
+ const pops = (mpacket && mpacket.properties) || {}
1081
+ if (subIdsAvailable && pops.subscriptionIdentifier && sops.subscriptionIdentifier && (pops.subscriptionIdentifier !== sops.subscriptionIdentifier)) {
1082
+ //do nothing as subscriptionIdentifier does not match
1083
+ } else if (matchTopic(topic, mtopic)) {
1084
+ subscription.callback && subscription.callback(mtopic, mpayload, mpacket)
1085
+ }
1086
+ } catch (err) {
1087
+ node.error("MQTT subscription handler error: " + err.toString());
1083
1088
  }
1084
1089
  }
1085
1090
  }
@@ -297,7 +297,11 @@ module.exports = function(RED) {
297
297
  }
298
298
  msg._session = {type:"websocket",id:id};
299
299
  for (var i = 0; i < this._inputNodes.length; i++) {
300
- this._inputNodes[i].send(msg);
300
+ try {
301
+ this._inputNodes[i].send(msg);
302
+ } catch (err) {
303
+ this.error(RED._("websocket.errors.send-error") + " " + err.toString());
304
+ }
301
305
  }
302
306
  }
303
307
 
@@ -127,32 +127,36 @@ module.exports = function(RED) {
127
127
  connectionPool[id] = client;
128
128
 
129
129
  client.on('data', function (data) {
130
- if (node.datatype != 'buffer') {
131
- data = data.toString(node.datatype);
132
- }
133
- if (node.stream) {
134
- var msg;
135
- if ((node.datatype) === "utf8" && node.newline !== "") {
136
- buffer = buffer+data;
137
- var parts = buffer.split(node.newline);
138
- for (var i = 0; i<parts.length-1; i+=1) {
139
- msg = {topic:node.topic, payload:parts[i]};
140
- if (node.trim == true) { msg.payload += node.newline; }
130
+ try {
131
+ if (node.datatype != 'buffer') {
132
+ data = data.toString(node.datatype);
133
+ }
134
+ if (node.stream) {
135
+ var msg;
136
+ if ((node.datatype) === "utf8" && node.newline !== "") {
137
+ buffer = buffer+data;
138
+ var parts = buffer.split(node.newline);
139
+ for (var i = 0; i<parts.length-1; i+=1) {
140
+ msg = {topic:node.topic, payload:parts[i]};
141
+ if (node.trim == true) { msg.payload += node.newline; }
142
+ msg._session = {type:"tcp",id:id};
143
+ node.send(msg);
144
+ }
145
+ buffer = parts[parts.length-1];
146
+ } else {
147
+ msg = {topic:node.topic, payload:data};
141
148
  msg._session = {type:"tcp",id:id};
142
149
  node.send(msg);
143
150
  }
144
- buffer = parts[parts.length-1];
145
151
  } else {
146
- msg = {topic:node.topic, payload:data};
147
- msg._session = {type:"tcp",id:id};
148
- node.send(msg);
149
- }
150
- } else {
151
- if ((typeof data) === "string") {
152
- buffer = buffer+data;
153
- } else {
154
- buffer = Buffer.concat([buffer,data],buffer.length+data.length);
152
+ if ((typeof data) === "string") {
153
+ buffer = buffer+data;
154
+ } else {
155
+ buffer = Buffer.concat([buffer,data],buffer.length+data.length);
156
+ }
155
157
  }
158
+ } catch (err) {
159
+ node.error(RED._("tcpin.errors.error",{error:err.toString()}));
156
160
  }
157
161
  });
158
162
  client.on('end', function() {
@@ -222,35 +226,39 @@ module.exports = function(RED) {
222
226
 
223
227
  var buffer = (node.datatype == 'buffer') ? Buffer.alloc(0) : "";
224
228
  socket.on('data', function (data) {
225
- if (node.datatype != 'buffer') {
226
- data = data.toString(node.datatype);
227
- }
228
- if (node.stream) {
229
- var msg;
230
- if ((typeof data) === "string" && node.newline !== "") {
231
- buffer = buffer+data;
232
- var parts = buffer.split(node.newline);
233
- for (var i = 0; i<parts.length-1; i+=1) {
234
- msg = {topic:node.topic, payload:parts[i], ip:socket.remoteAddress, port:socket.remotePort};
235
- if (node.trim == true) { msg.payload += node.newline; }
229
+ try {
230
+ if (node.datatype != 'buffer') {
231
+ data = data.toString(node.datatype);
232
+ }
233
+ if (node.stream) {
234
+ var msg;
235
+ if ((typeof data) === "string" && node.newline !== "") {
236
+ buffer = buffer+data;
237
+ var parts = buffer.split(node.newline);
238
+ for (var i = 0; i<parts.length-1; i+=1) {
239
+ msg = {topic:node.topic, payload:parts[i], ip:socket.remoteAddress, port:socket.remotePort};
240
+ if (node.trim == true) { msg.payload += node.newline; }
241
+ msg._session = {type:"tcp",id:id};
242
+ node.send(msg);
243
+ }
244
+ buffer = parts[parts.length-1];
245
+ } else {
246
+ msg = {topic:node.topic, payload:data, ip:socket.remoteAddress, port:socket.remotePort};
236
247
  msg._session = {type:"tcp",id:id};
237
248
  node.send(msg);
238
249
  }
239
- buffer = parts[parts.length-1];
240
- } else {
241
- msg = {topic:node.topic, payload:data, ip:socket.remoteAddress, port:socket.remotePort};
242
- msg._session = {type:"tcp",id:id};
243
- node.send(msg);
244
250
  }
245
- }
246
- else {
247
- if ((typeof data) === "string") {
248
- buffer = buffer+data;
249
- } else {
250
- buffer = Buffer.concat([buffer,data],buffer.length+data.length);
251
+ else {
252
+ if ((typeof data) === "string") {
253
+ buffer = buffer+data;
254
+ } else {
255
+ buffer = Buffer.concat([buffer,data],buffer.length+data.length);
256
+ }
257
+ fromi = socket.remoteAddress;
258
+ fromp = socket.remotePort;
251
259
  }
252
- fromi = socket.remoteAddress;
253
- fromp = socket.remotePort;
260
+ } catch (err) {
261
+ node.error(RED._("tcpin.errors.error",{error:err.toString()}));
254
262
  }
255
263
  });
256
264
  socket.on('end', function() {
@@ -678,117 +686,121 @@ module.exports = function(RED) {
678
686
  }
679
687
  var chunk = "";
680
688
  clients[connection_id].client.on('data', function(data) {
681
- if (node.out === "sit") { // if we are staying connected just send the buffer
682
- if (clients[connection_id]) {
683
- const msg = clients[connection_id].lastMsg || {};
684
- msg.payload = RED.util.cloneMessage(data);
685
- if (node.ret === "string") {
686
- try {
687
- if (node.newline && node.newline !== "" ) {
688
- chunk += msg.payload.toString();
689
- let parts = chunk.split(node.newline);
690
- for (var p=0; p<parts.length-1; p+=1) {
691
- let m = RED.util.cloneMessage(msg);
692
- m.payload = parts[p];
693
- if (node.trim == true) { m.payload += node.newline; }
694
- nodeSend(m);
689
+ try {
690
+ if (node.out === "sit") { // if we are staying connected just send the buffer
691
+ if (clients[connection_id]) {
692
+ const msg = clients[connection_id].lastMsg || {};
693
+ msg.payload = RED.util.cloneMessage(data);
694
+ if (node.ret === "string") {
695
+ try {
696
+ if (node.newline && node.newline !== "" ) {
697
+ chunk += msg.payload.toString();
698
+ let parts = chunk.split(node.newline);
699
+ for (var p=0; p<parts.length-1; p+=1) {
700
+ let m = RED.util.cloneMessage(msg);
701
+ m.payload = parts[p];
702
+ if (node.trim == true) { m.payload += node.newline; }
703
+ nodeSend(m);
704
+ }
705
+ chunk = parts[parts.length-1];
706
+ }
707
+ else {
708
+ msg.payload = msg.payload.toString();
709
+ nodeSend(msg);
695
710
  }
696
- chunk = parts[parts.length-1];
697
- }
698
- else {
699
- msg.payload = msg.payload.toString();
700
- nodeSend(msg);
701
711
  }
712
+ catch(e) { node.error(RED._("tcpin.errors.bad-string"), msg); }
702
713
  }
703
- catch(e) { node.error(RED._("tcpin.errors.bad-string"), msg); }
714
+ else { nodeSend(msg); }
704
715
  }
705
- else { nodeSend(msg); }
706
716
  }
707
- }
708
- // else if (node.splitc === 0) {
709
- // clients[connection_id].msg.payload = data;
710
- // node.send(clients[connection_id].msg);
711
- // }
712
- else {
713
- for (var j = 0; j < data.length; j++ ) {
714
- if (node.out === "time") {
715
- if (clients[connection_id]) {
716
- // do the timer thing
717
- if (clients[connection_id].timeout) {
718
- i += 1;
719
- buf[i] = data[j];
720
- }
721
- else {
722
- clients[connection_id].timeout = setTimeout(function () {
723
- if (clients[connection_id]) {
724
- clients[connection_id].timeout = null;
725
- const msg = clients[connection_id].lastMsg || {};
726
- msg.payload = Buffer.alloc(i+1);
727
- buf.copy(msg.payload,0,0,i+1);
728
- if (node.ret === "string") {
729
- try { msg.payload = msg.payload.toString(); }
730
- catch(e) { node.error("Failed to create string", msg); }
731
- }
732
- nodeSend(msg);
733
- if (clients[connection_id].client) {
734
- node.status({});
735
- clients[connection_id].client.destroy();
736
- delete clients[connection_id];
737
- }
738
- }
739
- }, node.splitc);
740
- i = 0;
741
- buf[0] = data[j];
742
- }
743
- }
744
- }
745
- // count bytes into a buffer...
746
- else if (node.out == "count") {
747
- buf[i] = data[j];
748
- i += 1;
749
- if ( i >= node.splitc) {
717
+ // else if (node.splitc === 0) {
718
+ // clients[connection_id].msg.payload = data;
719
+ // node.send(clients[connection_id].msg);
720
+ // }
721
+ else {
722
+ for (var j = 0; j < data.length; j++ ) {
723
+ if (node.out === "time") {
750
724
  if (clients[connection_id]) {
751
- const msg = clients[connection_id].lastMsg || {};
752
- msg.payload = Buffer.alloc(i);
753
- buf.copy(msg.payload,0,0,i);
754
- if (node.ret === "string") {
755
- try { msg.payload = msg.payload.toString(); }
756
- catch(e) { node.error("Failed to create string", msg); }
725
+ // do the timer thing
726
+ if (clients[connection_id].timeout) {
727
+ i += 1;
728
+ buf[i] = data[j];
757
729
  }
758
- nodeSend(msg);
759
- if (clients[connection_id].client) {
760
- node.status({});
761
- clients[connection_id].client.destroy();
762
- delete clients[connection_id];
730
+ else {
731
+ clients[connection_id].timeout = setTimeout(function () {
732
+ if (clients[connection_id]) {
733
+ clients[connection_id].timeout = null;
734
+ const msg = clients[connection_id].lastMsg || {};
735
+ msg.payload = Buffer.alloc(i+1);
736
+ buf.copy(msg.payload,0,0,i+1);
737
+ if (node.ret === "string") {
738
+ try { msg.payload = msg.payload.toString(); }
739
+ catch(e) { node.error("Failed to create string", msg); }
740
+ }
741
+ nodeSend(msg);
742
+ if (clients[connection_id].client) {
743
+ node.status({});
744
+ clients[connection_id].client.destroy();
745
+ delete clients[connection_id];
746
+ }
747
+ }
748
+ }, node.splitc);
749
+ i = 0;
750
+ buf[0] = data[j];
763
751
  }
764
- i = 0;
765
752
  }
766
753
  }
767
- }
768
- // look for a char
769
- else {
770
- buf[i] = data[j];
771
- i += 1;
772
- if (data[j] == node.splitc) {
773
- if (clients[connection_id]) {
774
- const msg = clients[connection_id].lastMsg || {};
775
- msg.payload = Buffer.alloc(i);
776
- buf.copy(msg.payload,0,0,i);
777
- if (node.ret === "string") {
778
- try { msg.payload = msg.payload.toString(); }
779
- catch(e) { node.error("Failed to create string", msg); }
754
+ // count bytes into a buffer...
755
+ else if (node.out == "count") {
756
+ buf[i] = data[j];
757
+ i += 1;
758
+ if ( i >= node.splitc) {
759
+ if (clients[connection_id]) {
760
+ const msg = clients[connection_id].lastMsg || {};
761
+ msg.payload = Buffer.alloc(i);
762
+ buf.copy(msg.payload,0,0,i);
763
+ if (node.ret === "string") {
764
+ try { msg.payload = msg.payload.toString(); }
765
+ catch(e) { node.error("Failed to create string", msg); }
766
+ }
767
+ nodeSend(msg);
768
+ if (clients[connection_id].client) {
769
+ node.status({});
770
+ clients[connection_id].client.destroy();
771
+ delete clients[connection_id];
772
+ }
773
+ i = 0;
780
774
  }
781
- nodeSend(msg);
782
- if (clients[connection_id].client) {
783
- node.status({});
784
- clients[connection_id].client.destroy();
785
- delete clients[connection_id];
775
+ }
776
+ }
777
+ // look for a char
778
+ else {
779
+ buf[i] = data[j];
780
+ i += 1;
781
+ if (data[j] == node.splitc) {
782
+ if (clients[connection_id]) {
783
+ const msg = clients[connection_id].lastMsg || {};
784
+ msg.payload = Buffer.alloc(i);
785
+ buf.copy(msg.payload,0,0,i);
786
+ if (node.ret === "string") {
787
+ try { msg.payload = msg.payload.toString(); }
788
+ catch(e) { node.error("Failed to create string", msg); }
789
+ }
790
+ nodeSend(msg);
791
+ if (clients[connection_id].client) {
792
+ node.status({});
793
+ clients[connection_id].client.destroy();
794
+ delete clients[connection_id];
795
+ }
796
+ i = 0;
786
797
  }
787
- i = 0;
788
798
  }
789
799
  }
790
800
  }
791
801
  }
802
+ } catch (err) {
803
+ node.error(RED._("tcpin.errors.error",{error:err.toString()}));
792
804
  }
793
805
  });
794
806
 
@@ -98,15 +98,19 @@ module.exports = function(RED) {
98
98
  });
99
99
 
100
100
  server.on('message', function (message, remote) {
101
- var msg;
102
- if (node.datatype =="base64") {
103
- msg = { payload:message.toString('base64'), fromip:remote.address+':'+remote.port, ip:remote.address, port:remote.port };
104
- } else if (node.datatype =="utf8") {
105
- msg = { payload:message.toString('utf8'), fromip:remote.address+':'+remote.port, ip:remote.address, port:remote.port };
106
- } else {
107
- msg = { payload:message, fromip:remote.address+':'+remote.port, ip:remote.address, port:remote.port };
101
+ try {
102
+ var msg;
103
+ if (node.datatype =="base64") {
104
+ msg = { payload:message.toString('base64'), fromip:remote.address+':'+remote.port, ip:remote.address, port:remote.port };
105
+ } else if (node.datatype =="utf8") {
106
+ msg = { payload:message.toString('utf8'), fromip:remote.address+':'+remote.port, ip:remote.address, port:remote.port };
107
+ } else {
108
+ msg = { payload:message, fromip:remote.address+':'+remote.port, ip:remote.address, port:remote.port };
109
+ }
110
+ node.send(msg);
111
+ } catch (err) {
112
+ node.error(RED._("udp.errors.error",{error:err.toString()}));
108
113
  }
109
- node.send(msg);
110
114
  });
111
115
 
112
116
  server.on('listening', function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-red/nodes",
3
- "version": "5.0.0-beta.2",
3
+ "version": "5.0.0-beta.3",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -15,9 +15,9 @@
15
15
  }
16
16
  ],
17
17
  "dependencies": {
18
- "acorn": "8.15.0",
19
- "acorn-walk": "8.3.4",
20
- "ajv": "8.17.1",
18
+ "acorn": "8.16.0",
19
+ "acorn-walk": "8.3.5",
20
+ "ajv": "8.18.0",
21
21
  "body-parser": "1.20.4",
22
22
  "cheerio": "1.0.0-rc.10",
23
23
  "content-type": "1.0.5",
@@ -35,8 +35,8 @@
35
35
  "is-utf8": "0.2.1",
36
36
  "js-yaml": "4.1.1",
37
37
  "media-typer": "1.1.0",
38
- "mqtt": "5.11.0",
39
- "multer": "2.0.2",
38
+ "mqtt": "5.15.0",
39
+ "multer": "2.1.1",
40
40
  "mustache": "4.2.0",
41
41
  "node-watch": "0.7.4",
42
42
  "on-headers": "1.1.0",