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

Fix issue causing 'subscription id too long' messages #1016

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

mplorentz
Copy link
Member

I made this change here with the comment (and I quote) "I'm not sure why we are sha256ing this at all." It turns out that if you don't sha256 it the subscription IDs can become very long and relays will reject subscriptions with messages like:

Notice from relay.damus.io: [NOTICE, ERROR: bad close: subscription id too long]

@@ -42,7 +42,7 @@ struct RelaySubscription: Identifiable {
) {
self.filter = filter
self.relayAddress = relayAddress
self.id = filter.id + "-" + relayAddress.absoluteString
self.id = (filter.id + "-" + relayAddress.absoluteString).data(using: .utf8)?.sha256 ?? "error"
Copy link
Member

Choose a reason for hiding this comment

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

I'm glad you spotted it. Do you mind adding a comment in the code linking to this PR? Just in case in the future we wonder the same thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea! Done!

@mplorentz mplorentz requested a review from martindsq April 9, 2024 18:30
@mplorentz mplorentz added this pull request to the merge queue Apr 9, 2024
Merged via the queue into main with commit 9995cf8 Apr 9, 2024
5 checks passed
@mplorentz mplorentz deleted the fix-long-subscription-ids branch April 9, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants