Skip to content

fix(auth, web): correct use of underlying useEmulator API, sync not async #5171

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

Merged
merged 1 commit into from
Mar 8, 2021

Conversation

mikehardy
Copy link
Contributor

@mikehardy mikehardy commented Feb 28, 2021

Description

My original implementation of auth.useEmulator for FlutterFire in #4263 used the underlying firebase-js-sdk incorrectly for the web implementation

Underlying web API for useEmulator is sync not async, so attempting to await it and call .then resulted in an error since no Promise was returned.

Supporting auth.useEmulator officially should still require the Firestore issue uncovered in firebase-js-sdk >= v8.0.1 to be resolved, tracked here #4127 - but if users are willing to pin firebase-js-sdk === v8.0.1 auth.useEmulator will now work for them and firebase web in general should work

For people testing this and using firestore on web: firebase-js-sdk v8.0.1 is reported to work with auth.useEmulator without triggering the problem described in #4127 - thanks to @wtfiwtz for success report

Related Issues

Fixes #5096

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 (flutter 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 (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

Copy link
Member

@russellwheatley russellwheatley left a comment

Choose a reason for hiding this comment

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

LGTM

@wtfiwtz
Copy link

wtfiwtz commented Mar 2, 2021

I found that this only works with the latest SDK - I was on 7.20.0 due to another issue.

<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.9/firebase-functions.js"></script>

... in index.html and it started working for me.

@mikehardy
Copy link
Contributor Author

@wtfiwtz The PR comment contains that direction yes - but please read it very carefully, there is a related issue #4127 that should give you pause if you are using firestore as you indicate...

@wtfiwtz
Copy link

wtfiwtz commented Mar 2, 2021

Thanks @mikehardy... that's why I was on 7.20.0 but it does work with 8.0.1 and doesn't trigger #4127 that way.

Cheers,
Nigel

@mikehardy
Copy link
Contributor Author

Great - I updated the description here to be very explicit about that v8.0.1 sweet spot - thanks for the success report

@Salakar Salakar merged commit e508917 into firebase:master Mar 8, 2021
@firebase firebase locked and limited conversation to collaborators Apr 8, 2021
@mikehardy mikehardy deleted the fix-auth-emulator-web branch November 13, 2024 13:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 [firebase_auth] FirebaseAuth useEmulator crashes on web
5 participants