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: do not allow using ref functions after provider has been disposed #3598

Closed

Conversation

mattermoran
Copy link

fixes #3522

Using ref functions of the disposed provider can lead to unexpected behaviors e.g providers may never be disposed and hang around indefinitely if subscribed to using Ref of a disposed provider.

@riverpod
Future<void> future1(Future1Ref ref) async {}

@riverpod
Future<void> future2(Future2Ref ref) async {
  await Future.delayed(const Duration(seconds: 3));
  await ref.watch(future1Provider.future);
}

In the above example future1Provider will still be watched forever if future2Provider is disposed before timer expires.

Will handle checklist items if this even correct solution.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).

  • I have updated the CHANGELOG.md of the relevant packages.
    Changelog files must be edited under the form:

    ## Unreleased fix/major/minor
    
    - Description of your change. (thanks to @yourGithubId)
  • If this contains new features or behavior changes,
    I have updated the documentation to match those changes.

Copy link

changeset-bot bot commented Jun 5, 2024

⚠️ No Changeset found

Latest commit: b7df31f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@rrousselGit
Copy link
Owner

This is breaking and would require a 3.0 version

The 3.0 dev branch already does this. So this PR is probably no-longer necessary.

@mattermoran
Copy link
Author

oh great, then it should be closed.

@mattermoran mattermoran closed this Jun 5, 2024
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.

Future provider memory leak
2 participants