ssbc/muxrpc

Lack of error handling in stream.read

Closed this issue · 4 comments

Related to ssb-tunnel, I got this error:

/root/ssb-room/node_modules/muxrpc/stream.js:57
        var name = data.name
                        ^

TypeError: Cannot read property 'name' of null
    at PacketStreamSubstream.stream.read (/root/ssb-room/node_modules/muxrpc/stream.js:57:25)
    at PacketStream._onstream (/root/ssb-room/node_modules/packet-stream/index.js:224:13)
    at PacketStream.write (/root/ssb-room/node_modules/packet-stream/index.js:135:41)
    at /root/ssb-room/node_modules/muxrpc/pull-weird.js:56:15
    at /root/ssb-room/node_modules/pull-stream/sinks/drain.js:24:37
    at /root/ssb-room/node_modules/pull-goodbye/node_modules/pull-stream/throughs/filter.js:17:11
    at Object.cb (/root/ssb-room/node_modules/packet-stream-codec/index.js:111:11)
    at drain (/root/ssb-room/node_modules/pull-reader/index.js:39:14)
    at more (/root/ssb-room/node_modules/pull-reader/index.js:55:13)
    at /root/ssb-room/node_modules/pull-reader/index.js:66:9

It's at this line:

muxrpc/stream.js

Lines 56 to 67 in 210fac6

stream.read = function (data, end) {
var name = data.name
var type = data.type
var err, value
stream.read = null
if(!isStream(type))
return stream.write(null, new Error('unsupported stream type:'+type))
//how would this actually happen?
if(end) return stream.write(null, end)

I think the end case should be checked before using data, but the first line assumes that data exists. I think the error handling hasn't felt 'necessary' so far, but ssb-tunnel is unconventional enough that it might hit more corner cases.

@staltz - it's funny that we both ran into this edge case in the same week ( #49 )

stale commented

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

Stop it, bot

hmm, why would this be happening? normally the outer stream will be the one that has the unexpected error. can anyone make (or at least describe) how to hit this edge case?