⚠ 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
- chore: update pion/ice to v4 by @achingbrain in #3175
- Implement error codes spec by @sukunrt in #2927
- swarm: remove unnecessary error log by @sukunrt in #3128
- test(p2p/protocol/identify): Fix user agent assertion in Go 1.24 by @Jorropo in #3177
- feat(swarm): logging waitForDirectConn return error by @wlynxg in #3183
- feat: add AutoTLS example by @2color in #3103
- autonatv2: allow multiple concurrent requests per peer by @sukunrt in #3187
New Contributors
- @achingbrain made their first contribution in #3175
Full Changelog: v0.39.0...v0.40.0