Better multistream select errors
Currently, errors that happen inside multistream-select are not very friendly:
Error: unexpected end of input
at Object.read (file:///usr/app/node_modules/it-length-prefixed-stream/node_modules/it-byte-stream/dist/src/index.js:86:31)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.read (file:///usr/app/node_modules/it-length-prefixed-stream/dist/src/index.js:45:37)
at async read (file:///usr/app/node_modules/@libp2p/multistream-select/dist/src/multistream.js:22:17)
at async Module.readString (file:///usr/app/node_modules/@libp2p/multistream-select/dist/src/multistream.js:33:17)
at async Module.select (file:///usr/app/node_modules/@libp2p/multistream-select/dist/src/select.js:72:20)
at async ConnectionImpl.newStream [as _newStream] (file:///usr/app/node_modules/libp2p/dist/src/upgrader.js:331:50)
at async ConnectionImpl.newStream (file:///usr/app/node_modules/libp2p/dist/src/connection/index.js:94:24)
at async file:///usr/app/packages/reqresp/lib/request/index.js:57:26
at async withTimeout (file:///usr/app/packages/utils/lib/timeout.js:15:16)
It may be nice to throw some error like: "Multistream-select protocol negotiation failed" or something like that.
Iirc, there's also an existing ProtocolNegotiationError that can be thrown (and that can be handled by consumers)
Error: unexpected end of input
This normally means the remote closed the connection/stream, though the reason is opaque. We can throw a ProtocolNegotiationError error locally instead though it still doesn't tell us what we should do differently next time we attempt that operation.
There's a discussion about providing more information to the remote peer when this happens and a spec PR for the same.