Better multistream select errors
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.6k
- Forks
- 546
- Avg merge
- 8h 18m
- Merged PRs (30d)
- 16
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing multistream-select through the multistream.js read path and select.js entry point shown in the stack trace. Inspect the existing ProtocolNegotiationError and determine how negotiation failures should be surfaced to consumers. Done means failures expose a friendly, handleable protocol-negotiation error instead of the underlying low-level error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100