Skip to content
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

swarm: log unexpected listener errors #2277

Merged
merged 2 commits into from
May 11, 2023
Merged

Conversation

MarcoPolo
Copy link
Collaborator

Closes #2264

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

A couple of nits, otherwise this lgtm.

@@ -127,6 +127,9 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error {
for {
c, err := list.Accept()
if err != nil {
if err != transport.ErrListenerClosed {
Copy link
Contributor

Choose a reason for hiding this comment

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

errors.Is?

@@ -152,8 +153,7 @@ func TestAcceptErrorGetCleanedUp(t *testing.T) {
require.NoError(t, err)
defer l.Close()
_, err = l.Accept(context.Background())
require.EqualError(t, err, "accept goroutine finished")

require.Equal(t, err, transport.ErrListenerClosed)
Copy link
Contributor

Choose a reason for hiding this comment

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

require.ErrorIs?

@@ -134,6 +136,9 @@ func (l *connListener) Run() error {
for {
conn, err := l.l.Accept(context.Background())
if err != nil {
if err == quic.ErrServerClosed || strings.Contains(err.Error(), "use of closed network connection") {
Copy link
Contributor

Choose a reason for hiding this comment

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

errors.Is?

@@ -127,6 +127,9 @@ func (s *Swarm) AddListenAddr(a ma.Multiaddr) error {
for {
c, err := list.Accept()
if err != nil {
if err != transport.ErrListenerClosed {
log.Error("swarm listener accept error: ", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this include which listener this is? For example:

Suggested change
log.Error("swarm listener accept error: ", err)
log.Errorf("swarm listener for %s accept error: %s", a, err)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you think about using "%T" to print the type? I think it'll be more useful than trying to print the fields on some unknown struct.

Copy link
Contributor

Choose a reason for hiding this comment

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

What fields of an unknown struct? a is the multiaddr.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. I misread this as log.Errorf("swarm listener %s accept error: %s", list, err). That makes sense.

@marten-seemann marten-seemann merged commit 22a70b4 into master May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log error in accept
2 participants