Skip to content

v0.40.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 17 Feb 20:25
ce33562

⚠ Breaking Change!

Introducing error codes mandated changing the error types returned by stream resets. All checks that depended on checking the error string or comparing equality with network.ErrReset, now need to use errors.Is(err, network.ErrReset). More details below in the error codes section.

🔦 Highlights

Error Codes

This releases introduces error codes for Stream Reset and Connection Close. This allows sending for more information to the peer about the error condition causing the abort. go-libp2p has already defined some error codes which are useful for many different use cases. You can find them in:
https://github.com/libp2p/go-libp2p/blob/master/core/network/mux.go#L46
and: https://github.com/libp2p/go-libp2p/blob/master/core/network/conn.go#L47
<TODO: Replace with pkg.go.dev link post release>

On streams, you can signal an error on reset by using:

str.ResetWithError(errCode)

On connections, you can signal an error on close by using:

conn.ResetWithError(errCode)

Not all transports support error codes. Most notably, WebTransport has no support for sending error codes at the moment. See the spec: libp2p/specs#623 for more details.

If you want to define custom error codes for your application protocol, you can reserve a block for your application by opening a PR in the specs repo. The above mentioned spec has details on reserving error codes for applications. Until the spec is merged, you must open a PR targeting the spec's branch.

Breaking Change!

This introduces a breaking change for users who checked stream reset errors by testing for equality with network.ErrReset as err == network.ErrReset. These tests now need to use the errors.Is(err, network.ErrReset) test. Stream Resets now return either *network.StreamError if the stream was reset by remote, or *network.ConnError if the connection was closed by remote.

What's Changed

New Contributors

Full Changelog: v0.39.0...v0.40.0