Skip to content

Better multistream select errors #3210

@wemeetagain

Description

@wemeetagain

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/enhancementA net-new feature or improvement to an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions