-
Notifications
You must be signed in to change notification settings - Fork 929
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
Emulator: auth functions not triggered #2847
Comments
@jonadeline have you called |
Hi @samtstern, yep the user creation is working like a charm in the emulator. I can see it in the Emulator UI. |
@jonadeline I am able to reproduce this as well: functions/index.js const functions = require('firebase-functions');
exports.onNewUser = functions.auth.user().onCreate((user, ctx) => {
console.log(JSON.stringify(user));
return true;
}); public/index.html <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome to Firebase Hosting</title>
<script defer src="/__/firebase/8.1.1/firebase-app.js"></script>
<script defer src="/__/firebase/8.1.1/firebase-auth.js"></script>
<script defer src="/__/firebase/init.js?useEmulator=true"></script>
</head>
<body>
<div id="message">
<h2>Welcome</h2>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const username = `user${new Date().getTime()}@example.com`;
const password = 'password';
firebase.auth().createUserWithEmailAndPassword(username, password)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.warn(err);
});
});
</script>
</body>
</html> I see the users created in the Emulators UI but there are no function logs reporting that the auth function ran:
Even when creating a user directly in the UI, no functions run. |
@abeisgoat @yuchenshi this seems like a big bug, do we have tests covering this? Am I missing something? |
We don't have integration tests with client SDKs and let's add those as a first step. (We do have them for users created by admin SDKs). After that, we should be able to reproduce it and catch regressions in the future. |
@jonadeline @samtstern i am also able to reproduce this bug locally. In the interim, connecting auth directly to a test gcp project environment to test OAuth flows work, but not ideal for testing integration with rest of firebase emulator services. |
@jonadeline @NMVW I just tried this again and so did @yuchenshi and we're no longer able to reproduce the issue:
Are you sure your functions emulator is running with the same project ID that you're using with the Web SDK? |
Yes, on my side I set the Here is how I start the emulator : But the connexion between the emulator and the client side looks good as regular firebase functions are triggered correctly in the emulator on my environnement. |
I am having the same issue. Other Functions are working "https.onCall" Debugger jumps to breakpoints etc, but auth.user().onCreate is not firing, don't know if the emulator suite emulates this behaviour but auth.user().onCreate also does not fire when creating a user from the emulator dashboard. |
@jonadeline @johanbuys would you please do me a favor and try |
I created this repository to demonstrate another issue but I am also facing the issue that the |
Hi just tested with: Edit: |
Not better on my side. 😞 |
@itsmeneartou I was able to clone and run your reproduction, thanks for providing it! When I signed in to the Angular app I can confirm that no Cloud Function triggered, but I also didn't see any user in my Emulator UI so I don't think the frontend is talking to the Auth Emulator at all. I suspect this is because you're using FirebaseUI, which does not yet have support for the Firebase Auth emulator. |
@johanbuys does removing the |
Confirming that in my environment I am also relying on FirebaseUI for auth flows |
I have changed region and no effect. I too have been using firebaseUI. However I am adding users from the emulator frontend now, would this not trigger the function? (The docs state that creating a user from the Firebase console will trigger the function, not sure if this behaviour is emulated.) |
fyi I am not using firebaseUI |
@johanbuys @jonadeline yes if you add a user through the Emulator UI and don't see your functions triggered that's a bug, and that's probably the easiest place for us to focus going forward since it removes variables of how people use their web frontend (FirebaseUI, etc) |
@samtstern yes that's the behaviour I am experiencing, create user from ui, function not firing. I have a debugger attached does not hit the bp. |
same for me |
I have found this issue today, im using emulator since few weeks back and ir works fine but today i had to implement my first auth event (onCreate) and it doesnt get triggered. no region. |
Hi, Also one thing to note is that firebase-ui is not compatible with the auth emulator the firebase-ui team is still working on getting it to work. When using Firebase-ui it will send all comms to the configured project directly. NB: So when you use firebase-ui all auth requests will bypass the emulator (even if see here: firebase/firebaseui-web#778 (comment) |
Hey everyone it's been a while since we last got a report of this issue. Reading through the thread again it sounds like some combination of the following will fix it:
I'm going to close this one, but if anyone sees this issue again just let me know and we can reopen it. |
It seems that the firebase functions based on auth events (in my case functions.auth.user().onCreate) are not triggered within the emulator suite.
In Emulator UI i'm able to see that my auth function is initialized correctly but nothing happens when a user is created (from client side with
auth.createUserWithEmailAndPassword()
method)I set the required env variables (FIREBASE_AUTH_EMULATOR_HOST and GCLOUD_PROJEC) when launching the emulator
My dependencies are up to date :
firebase-tools 8.16.2
firebase-admin: 9.4.1
firebase-functions: 3.11.0
Note : regular firebase functions are triggered properly in the emulator.
The text was updated successfully, but these errors were encountered: