fix bug with incoming packet cloning

tls
David Kebler 2018-02-23 21:17:37 -08:00
parent 19a2b6a150
commit 283957f641
1 changed files with 2 additions and 3 deletions

View File

@ -86,9 +86,8 @@ export default class Socket extends Server {
// TODO need to start error listener for stream so errors can be processed
stream.on('message', messageProcess.bind(this))
async function messageProcess (packet) {
let res = clone(packet)
// console.log(' incoming packet on socket side',packet)
res = clone((await this._packetProcess(res)),false)
//console.log(' incoming packet on socket side',packet)
let res = await this._packetProcess(clone(packet))
if (Object.keys(res).length === 0) res = { error: 'socket packet command function likely did not return a promise', packet:packet}
res._header = clone(packet._header,false) //make sure return packet has header with id in case it was removed in processing
delete packet._header // remove before adding to response header as request