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

feat!: add disconnectTimeout option to rx-nostr config #165

Merged
merged 9 commits into from
Jan 15, 2025

Conversation

hzrd149
Copy link
Contributor

@hzrd149 hzrd149 commented Jan 13, 2025

This is my best attempt at adding a disconnect timeout option to rx-nostr to address #164

Let me know if you think there is a better way to implement this but I think I made it pretty simple :)

@penpenpng penpenpng self-requested a review January 14, 2025 13:02

/**
* How long a relay connection should be held open when no longer used
* @default 0
Copy link
Owner

Choose a reason for hiding this comment

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

Nice annotation👍. I will introduce this in other doc comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it makes sense to add a default timeout of 10000 ( 10s )?
Currently rx-nostr makes a lot of connections to temporary relays or even the default ones when its set to lazy and its much smoother if it keeps the connections open for a while

I wanted to ask first since its maybe a breaking change

Copy link
Owner

Choose a reason for hiding this comment

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

As you mention, it is a breaking change but certainly makes sense. In my personal opinion I find it acceptable to include it in this minor update. Let's change it to 10000.

It will break some test cases so please set disconnectTimeout: 0 to fix them.

Copy link
Owner

Choose a reason for hiding this comment

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

@hzrd149 Do you change the default value in this PR? If not, I will merge soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a default of 10000 (10s) and updated the tests

@@ -48,6 +49,13 @@ export interface RxNostrConfig {
* Auto reconnection strategy.
*/
retry?: RetryConfig;

/**
* How long a relay connection should be held open when no longer used
Copy link
Owner

Choose a reason for hiding this comment

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

I think we should explain that it only affect lazy strategy relays and default relays.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@penpenpng
Copy link
Owner

@hzrd149 I think the implementation is very simple and great! Could you update the doc comment to show what relays the option affects?

@penpenpng penpenpng changed the title add disconnectTimeout option to rx-nostr config feat: add disconnectTimeout option to rx-nostr config Jan 14, 2025
@penpenpng penpenpng changed the title feat: add disconnectTimeout option to rx-nostr config feat!: add disconnectTimeout option to rx-nostr config Jan 15, 2025
Copy link
Owner

@penpenpng penpenpng left a comment

Choose a reason for hiding this comment

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

Thank you!

@penpenpng penpenpng merged commit 50d0d8f into penpenpng:main Jan 15, 2025
2 checks 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