Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: survive bad network requests (#222)
* fix: survive not being able to send messages to peers Builds on the work in #221 I see intermittant but frequent CI errors with js-ipfs, usually after a test has finished and the ndoes are being torn down. Getting it to do some additional logging reveals bitswap is crashing when it cannot send a message to a remote peer due to the libp2p dial failing: ```console ipfs: [stdout] Error: stream ended before 1 bytes became available ipfs: at /home/travis/build/ipfs/js-ipfs/node_modules/it-reader/index.js:37:9 ipfs: at processTicksAndRejections (internal/process/task_queues.js:97:5) ipfs: at async /home/travis/build/ipfs/js-ipfs/node_modules/it-length-prefixed/src/decode.js:80:20 ipfs: at async oneChunk (/home/travis/build/ipfs/js-ipfs/node_modules/multistream-select/src/multistream.js:12:20) ipfs: at async Object.exports.read (/home/travis/build/ipfs/js-ipfs/node_modules/multistream-select/src/multistream.js:34:15) ipfs: at async module.exports (/home/travis/build/ipfs/js-ipfs/node_modules/multistream-select/src/select.js:21:19) ipfs: at async ClassIsWrapper.newStream [as _newStream] (/home/travis/build/ipfs/js-ipfs/node_modules/libp2p/src/upgrader.js:251:40) ipfs: at async ClassIsWrapper.newStream (/home/travis/build/ipfs/js-ipfs/node_modules/libp2p-interfaces/src/connection/connection.js:172:34) ipfs: at async Network.sendMessage (/home/travis/build/ipfs/js-ipfs/node_modules/ipfs-bitswap/src/network.js:147:34) ipfs: at async DecisionEngine._processTasks (/home/travis/build/ipfs/js-ipfs/node_modules/ipfs-bitswap/src/decision-engine/index.js:124:5) { ipfs: code: 'ERR_UNSUPPORTED_PROTOCOL', ipfs: buffer: BufferList { _bufs: [], length: 0 } ipfs: } ``` This PR adds a try/catch around network send operations. At the moment it just dumps the request, I'm not sure if we want to add a retry in there or something.
- Loading branch information