-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement error codes spec #2927
Conversation
a6e85e0
to
b7d79b0
Compare
66c8cdb
to
53d436f
Compare
3d1038b
to
aa8b049
Compare
d6baf8e
to
1ad628f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a couple of small comments.
Do we have a PR that updates the WebRTC spec changes?
|
||
// ResetWithError closes both ends of the stream with errCode. The errCode is sent | ||
// to the peer. | ||
ResetWithError(errCode StreamErrorCode) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about CloseWithError
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need that? Close implies non error reliable close, no? For instance, we also flush all writes, and retransmit if necessary, when calling Close
.
p2p/net/mock/mock_stream.go
Outdated
@@ -144,6 +144,22 @@ func (s *stream) Reset() error { | |||
return nil | |||
} | |||
|
|||
func (s *stream) ResetWithError(errCode network.StreamErrorCode) error { | |||
// Cancel any pending reads/writes with an error. | |||
// TODO: Should these be the other way round(remote=true)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The errors will be returned to the other side of the pipe. In this case the peer will see these errors, so we should set remote=true
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm removing support for error codes here. It's a much larger change. We need to propogate resets from read as well. I'll add it in a follow up PR.
p2p/transport/quic/stream.go
Outdated
if errors.As(err, &se) { | ||
code := se.ErrorCode | ||
if code > math.MaxUint32 { | ||
// TODO(sukunrt): do we need this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably set the code to a sentinel value that signifies there was an error converting the transport code to a libp2p code. We also need to update the specs to mention this case (in case we haven't).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a sentinel code. libp2p/specs@4eca305
354fbdc
to
798258c
Compare
Should we add I can introduce that in a follow up PR. |
p2p/test/transport/transport_test.go
Outdated
}) | ||
}) | ||
|
||
t.Run("StreamResetByConnCloseWithError", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should likely be called "NewStreamsErrByConnCloseWithError"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split this into two
- Stream methods should get the connection close error code if the connection was closed.
Conn.NewStream
should get the connection close error code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple minor things to fix, but looks good!
@@ -56,6 +56,12 @@ func (s *stream) Reset() error { | |||
return nil | |||
} | |||
|
|||
func (s *stream) ResetWithError(_ network.StreamErrorCode) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave a comment with some context for why we can't do this yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added some text.
6a39dda
to
be45dcb
Compare
be45dcb
to
146812c
Compare
146812c
to
dfa7e28
Compare
4df0ee3
to
1c3909d
Compare
The type ErrNotSupported introduced in multiformats/go-multistream#114 handles the lazy handshake fail correctly.
f721398
to
cb1cfc1
Compare
cb1cfc1
to
a4d9781
Compare
Specification: libp2p/specs#479