Open akloboucnik opened 6 years ago
If peer is unable to parse message for specific reasons it should not throw error but reply with a reject message.
reject
I've stumble upon this in our code, we see exceptions like:
2018-05-11T11:47:34.663Z ERROR <module> Uncaught exception: { stack: [ 'Error: Data still available after parsing', 'at Object.checkFinished (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/utils.js:20:13)', 'at AddrMessage.setPayload (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/commands/addr.js:48:9)', 'at Function.exported.commands.(anonymous function).fromBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/builder.js:75:15)', 'at Messages._buildFromBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:103:41)', 'at Messages.parseBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:74:15)', 'at Peer._readMessage (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:219:31)', 'at Socket.<anonymous> (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:167:10)', 'at emitOne (events.js:116:13)', 'at Socket.emit (events.js:211:7)', 'at addChunk (_stream_readable.js:263:12)' ], message: 'Data still available after parsing' }
or
2018-05-11T11:01:30.571Z ERROR <module> Uncaught exception: { stack: [ 'Error: Unsupported message command: encinit', 'at Messages._buildFromBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:101:11)', 'at Messages.parseBuffer (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/messages/index.js:74:15)', 'at Peer._readMessage (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:219:31)', 'at Socket.<anonymous> (/Users/adam/Work/blockcollider/bcnode/node_modules/bitcore-p2p/lib/peer.js:167:10)', 'at emitOne (events.js:116:13)', 'at Socket.emit (events.js:211:7)', 'at addChunk (_stream_readable.js:263:12)', 'at readableAddChunk (_stream_readable.js:250:11)', 'at Socket.Readable.push (_stream_readable.js:208:10)', 'at TCP.onread (net.js:594:20)' ], message: 'Unsupported message command: encinit' }
Coverage decreased (-0.09%) to 99.534% when pulling 5c56eb7d52063f2cee56f45c580373550df8a4b7 on akloboucnik:fix-unknown-message-or-malformed-payload into 10a21524d875efd8d28d4207011f391d778609d6 on bitpay:master.
Hi @maraoz is there any plan to merge this? Or fix the issue mentioned by @akloboucnik ?
Hi @maraoz! Is there any chance of this getting merged?
I no longer have commit access to this repo, sorry!
If peer is unable to parse message for specific reasons it should not throw error but reply with a
reject
message.I've stumble upon this in our code, we see exceptions like:
or