Repository navigation
Closed
Description
I'm trying to get the beforeSignin trigger function to work using the emulator on demo projects (--project demo-xxxx / 12.7.0 / macOS) but that's not triggering while perfectly working in production. I'm able to login and write to the database in the emulator, but no beforeSignin trigger. I've spent the whole day trying, but nothing in the logs.
I double checked that both auth and functions are started and running in the emulator, and correctly set the projectId to demo-test in my client as suggested:
initializeApp({
projectId: "demo-test",
apiKey: "useless",
databaseURL: "https://demo-test.firebaseio.com",
})
const auth = getAuth()
connectAuthEmulator(auth, "http://127.0.0.1:9099")
auth.settings.appVerificationDisabledForTesting = trueI also tried to to set the projectId in the function, which should be useless, but with no luck:
import {beforeUserSignedIn} from "firebase-functions/v2/identity"
import {initializeApp} from "firebase-admin/app"
initializeApp({
projectId: "demo-test",
})
export const beforesignin = beforeUserSignedIn(async (event) => {
console.log(`beforesignin: ${JSON.stringify(event.data)}`)
})Is there anything else I'm not aware of to get it working on demo-projects emulation ?
➜ firebase emulators:start --project demo-test
i emulators: Starting emulators: auth, functions, database
i emulators: Detected demo project ID "demo-test", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.
i database: Database Emulator logging to database-debug.log
i ui: Emulator UI logging to ui-debug.log
✔ functions: Loaded functions definitions from source: beforesignin.
✔ functions[us-central1-beforesignin]: providers/cloud.auth/eventTypes/user.beforeSignIn function initialized (http://127.0.0.1:5001/demo-test/us-central1/beforesignin).
┌─────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your app. │
│ i View Emulator UI at http://127.0.0.1:4000/ │
└─────────────────────────────────────────────────────────────┘
┌────────────────┬────────────────┬─────────────────────────────────┐
│ Emulator │ Host:Port │ View in Emulator UI │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Authentication │ 127.0.0.1:9099 │ http://127.0.0.1:4000/auth │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Functions │ 127.0.0.1:5001 │ http://127.0.0.1:4000/functions │
├────────────────┼────────────────┼─────────────────────────────────┤
│ Database │ 127.0.0.1:9000 │ http://127.0.0.1:4000/database │
└────────────────┴────────────────┴─────────────────────────────────┘
Emulator Hub running at 127.0.0.1:4400
Other reserved ports: 4500
Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.Reacted by Brayden
Activity
aalej commentedon Nov 6, 2023
Hi @renaudcerrato, thanks for the detailed report. I’m currently unable to reproduce the behavior you mentioned. Using the code snippets you provided, I created this repo to try and replicate the issue. Let me know in case I’m missing anything.
I added an
authDomainin theinitializeApp:And removed a section in the functions code related to the Admin SDK:
By any chance, if you’re unable to reproduce the issue using the repo, could you provide a Minimal, Complete, and Verifiable Example (MCVE)? This is so that we can replicate the issue on our end.
renaudcerrato commentedon Nov 8, 2023
Thanks for the repo, it seems the
authDomaindid the trick!renaudcerrato commentedon Nov 8, 2023
Hey @aalej : just been able to reproduce the issue in your repo by adding a pubsub function to the project. Please look at aalej/issues-6494#1
aalej commentedon Nov 9, 2023
Thanks @renaudcerrato for additional information. I was able to reproduce the issue you mentioned after adding the code you provided. I’ll notify our engineering team about this so that they can take a look, and I’ll be marking this as reproducible.