Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

[WIP] feat: handle stream muxer errors #245

Closed
wants to merge 4 commits into from
Closed

Conversation

dryajov
Copy link
Member

@dryajov dryajov commented Feb 28, 2018

I'm not sure why we weren't handling stream muxer errors here at all, but if there is a good reason and the error handling changes are not needed we can revert them. The really important change is in libp2p-mplex (libp2p/js-libp2p-mplex#75) that prevents the throw from crashing the entire node.

improve circuit relay error msgs
@ghost ghost assigned dryajov Feb 28, 2018
@ghost ghost added the in progress label Feb 28, 2018
@dryajov dryajov changed the title feat: handle stream muxer errors [WIP] feat: handle stream muxer errors Feb 28, 2018
@dryajov
Copy link
Member Author

dryajov commented Feb 28, 2018

Requires - libp2p/js-libp2p-mplex#75

@daviddias daviddias requested review from dignifiedquire, pgte and daviddias and removed request for dignifiedquire March 2, 2018 13:25
@@ -22,14 +22,15 @@ const Switch = require('../src')
describe('Stream Multiplexing', () => {
[
multiplex,
spdy
spdy // TODO: do we still support this?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course we still support. The whole design of libp2p is to support multiple building blocks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spdy doesn't return any errors when the stream abruptly terminates. We should make the behaviour consistent then.

What should happen - error on abrupt termination or silent skip?

it('should fail graciously on dead stream mux', function (done) {
if (sm.multicodec === '/spdy/3.1.0') {
this.skip()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No skipping for SPDY

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skipping because the behaviour is not consistent across muxers - spdy doesn't return any errors on abrupt termination.

src/dial.js Outdated
}

cb(null, conn)
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just newStream(cb)?

src/dial.js Outdated
@@ -208,7 +213,13 @@ function dial (swtch) {
}

function openConnInMuxedConn (muxer, cb) {
cb(muxer.newStream())
muxer.newStream((err, conn) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This asking to change the Stream Muxer interface. https://github.com/libp2p/interface-stream-muxer needs to be updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really change newStream interface, it already takes a callback as it is. I reverted this to return a connection as before. This PR just tries to propagate the error if it's returned by the multiplexer - before it would just be ignored.

@dryajov
Copy link
Member Author

dryajov commented Mar 2, 2018

@diasdavid

I'm still not sure if we need this at all. This change was driven by -libp2p/js-libp2p-mplex#75, which would simply throw on error and crash the whole process. Since I return the error now, it seemed logical to handle it here. Other multiplexer however (spdy) don't seem to follow the same behaviour (not even sure if they can).

So the question remains - should we handle the errors in switch or just ignore them?

@coveralls
Copy link

Pull Request Test Coverage Report for Build #6

  • 0 of 0 (NaN%) changed or added relevant lines in 0 files are covered.
  • 9 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+1.3%) to 89.139%

Files with Coverage Reduction New Missed Lines %
../src/dial.js 9 87.36%
Totals Coverage Status
Change from base Build #5: 1.3%
Covered Lines: 544
Relevant Lines: 585

💛 - Coveralls

@harrshasri
Copy link
Contributor

@pgte Any update on this thread? When can I expect this issue to be fixed. If anyone can direct me what needs to be done. I can hop on fixing this.

@pgte
Copy link
Contributor

pgte commented Apr 4, 2018

@harrshasri I'm not the one assigned to this. You should probably be speaking to @dryajov :)

@harrshasri
Copy link
Contributor

@pgte Aah ... Okay I did tag you just because you were requested for reviewing this.

@dryajov
Copy link
Member Author

dryajov commented Apr 4, 2018

Thanks for bringing this up @harrshasri, this issue needs some clarification for sure! The current state is as follows:

Also libp2p/js-libp2p-mplex#75 might not be required anymore since libp2p/js-libp2p-mplex#76 is almost here, but untill then the above dependencies need to be resolved.

@dryajov
Copy link
Member Author

dryajov commented Jul 9, 2018

not relevant anymore

@dryajov dryajov closed this Jul 9, 2018
@ghost ghost removed the in progress label Jul 9, 2018
@daviddias daviddias deleted the feat/mplex-errs branch July 10, 2018 19:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants