Skip to content

fix(auth, web): stream handlers are properly cleaned up and recreated - #12903

Merged
russellwheatley merged 4 commits into
masterfrom
fix-web-hot-restart
Jun 5, 2024
Merged

russellwheatley merged 4 commits into
masterfrom
fix-web-hot-restart

Conversation

@russellwheatley

@russellwheatley russellwheatley commented Jun 5, 2024 •

Copy link
Copy Markdown
Member

Description

I was going to fix this issue, but realised web never properly cleans up the event listeners in the interop layer. i.e the onDispose() function was never called for onAuthStateChanged & onIdTokenChanged.

Ideally, I would've mocked to see the stream handlers created/removed in FirebaseAuthWeb, but mocking the interop layer with staticInterop was extremely difficult and I opted to create an integration test.

Also userStateChanges isn't a real API so it can't be cleaned up on JS side. The problem is; if you have both userStateChanges & onIdTokenChanged stream handlers and you want to clean them up, we have to check the other stream handler has no listeners which is the purpose of these booleans.

I've also updated the clean up code to match what we already have when initialising auth on web. My local testing shows that stream handlers are cleaned up.

Once this PR is merged, I'll fix the multiple stream handler creation bug for web hot restarts

Related Issues

Replace this paragraph with a list of issues related to this PR from the issue database. Indicate, which of these issues are resolved or fixed by this PR. Note that you'll have to prefix the issue numbers with flutter/flutter#.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@Lyokone Lyokone left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor comment

@russellwheatley
russellwheatley merged commit daaef12 into master Jun 5, 2024
@russellwheatley
russellwheatley deleted the fix-web-hot-restart branch June 5, 2024 14:19
@firebase firebase locked and limited conversation to collaborators Jul 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [Auth, Firestore, Storage, ...] Event Listeners are Not Properly Disposed on Web Hot Restart across all plugins.

3 participants