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

chore: log relay errors only once per app #131

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

im-adithya
Copy link
Member

Now we only log once instead of per subscription which bloats DD

continue
}

sub, err := relay.Subscribe(ctx, []nostr.Filter{*filter})
if err != nil {
// TODO: notify user about subscription failure
Copy link

Choose a reason for hiding this comment

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

I think we should still log an error here, shouldn't we?

Copy link
Member Author

Choose a reason for hiding this comment

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

This error never happened (in absolute terms), that's why I was confident of it, but doesn't hurt to log, should Ii add it back?

@@ -713,7 +713,6 @@ func (svc *Service) startSubscription(ctx context.Context, subscription *Subscri
var relay *nostr.Relay
var isCustomRelay bool
var err error
waitToReconnectSeconds := 0
Copy link

Choose a reason for hiding this comment

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

A few lines down (line 726) we cancel the subscription and return if there is an error. I think we should only exit this loop when the context.Done channel receives a message, and we should handle it in one place like we do in Alby Hub.

if err == nil {
svc.Relay = relay
}
return svc.Relay, false, err
}
}

func (svc *Service) relayConnectWithBackoff(ctx context.Context, relayURL string) (relay *nostr.Relay, err error) {
Copy link

Choose a reason for hiding this comment

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

Nice idea 👍

@im-adithya
Copy link
Member Author

The feedback here is noted, and will be addressed in a PR which aims to separate one-off subscriptions (as both comments refer to code in startSubscription function

@im-adithya im-adithya merged commit 59c0ab6 into task-logging Dec 20, 2024
1 check passed
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.

2 participants