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

Warn about unclosed Flux subscriptions #2738

Open
Legioth opened this issue Sep 17, 2024 · 0 comments
Open

Warn about unclosed Flux subscriptions #2738

Legioth opened this issue Sep 17, 2024 · 0 comments
Labels
enhancement New feature or request hilla Issues related to Hilla

Comments

@Legioth
Copy link
Member

Legioth commented Sep 17, 2024

Describe your motivation

When you open a Flux subscription, you are also responsible for eventually closing the subscription. Failing to do so may lead to leaking memory both in the browser and on the server. The problem is that application developer might not be aware that they need to do this.

Describe the solution you'd like

We could register any opened subscription in a FinalizationRegistry and unregister them when the subscription is closed. If we ever receive an event from the registry, then we would log a warning to the developer.

We could also trigger a proper disconnection at that point but that would lead to issues with existing code that have a "singleton" subscription that is supposed to remain open until the application is closed. Such cases would not have any need to store a reference to the subscription which in turn means that it would be immediately garbage collected and thus also closed.

Describe alternatives you've considered

Let buggy applications leak memory.

Additional context

No response

@Legioth Legioth added enhancement New feature or request hilla Issues related to Hilla labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hilla Issues related to Hilla
Projects
None yet
Development

No branches or pull requests

1 participant