Ensure message format availability
Make sure the entire process doesn't crash when a message is sent without `type` and/or `data` as such: ``` error: Uncaught Exception TypeError: Cannot read property 'id' of undefined at Server.gotData (/usr/src/app/node_modules/@trail/pigeoneer/node_modules/node-ipc/dao/socketServer.js:181:24) at emitOne (events.js:101:20) at Socket.emit (events.js:188:7) at Socket.EventEmitter.emit (/usr/src/app/node_modules/@trail/pigeoneer/node_modules/sc-domain/index.js:12:31) at readableAddChunk (_stream_readable.js:176:18) at Socket.Readable.push (_stream_readable.js:134:10) at TCP.onread (net.js:548:20) ```
This commit is contained in:
parent
e7739111fc
commit
8de357f488
1 changed files with 6 additions and 1 deletions
|
@ -175,7 +175,12 @@ function gotData(socket,data,UDPSocket){
|
||||||
while(data.length>0){
|
while(data.length>0){
|
||||||
let message=new Message;
|
let message=new Message;
|
||||||
message.load(data.shift());
|
message.load(data.shift());
|
||||||
|
|
||||||
|
// In case either `type` or `data` is missing we won't process this message.
|
||||||
|
if (!message.type || !message.data) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
this.log('received event of : ',message.type,message.data);
|
this.log('received event of : ',message.type,message.data);
|
||||||
|
|
||||||
if(message.data.id){
|
if(message.data.id){
|
||||||
|
|
Loading…
Reference in a new issue