firebase-tools: 8.14.1
Platform: macOS 10.15.7
Having a file /auth/onCreateUser.ts containing:
const onCreateUser = functions
.region(firebaseConfig.region)
.auth.user()
.onCreate(async (user) => {
// ... do something
})
export default onCreateUser
/auth/index.ts:
export { default as onCreateUser } from './onCreateUser'
index.ts:
import * as admin from 'firebase-admin';
import 'firebase-functions';
// Start writing Firebase Functions
// https://firebase.google.com/docs/functions/typescript
admin.initializeApp();
export * as auth from './auth';
firebase emulators:start;
auth-onCreateUser is triggered.
auth-onCreateUser is not triggered.
The name of the trigger should be auth-onCreateUser (or auth.auth-onCreateUser maybe?) but emulator is searching for auth.onCreateUser and it responds with the following error.
FirebaseError: No trigger with name auth.onCreateUser
If I deploy the trigger, I can see the correct name on the list, and it's triggered correctly when a new user is created. So the issue is only for the emulator in combination with auth triggers (had no time to test on database triggers).
For "normal" functions, using this splitting method works as expected.
[debug] [2020-10-29T18:45:13.185Z] [worker-~diagnostic~-2c3ef8a2-33d7-4475-8de3-599e66091204]: IDLE {"metadata":{"emulator":{"name":"functions"},"message":"[worker-~diagnostic~-2c3ef8a2-33d7-4475-8de3-599e66091204]: IDLE"}}
[debug] [2020-10-29T18:45:35.486Z] [work-queue] {"queueLength":1,"workRunningCount":0}
[debug] [2020-10-29T18:45:35.487Z] [work-queue] {"queueLength":0,"workRunningCount":1}
[debug] [2020-10-29T18:45:35.487Z] Accepted multicast request POST /functions/projects/lu-echo-dev/trigger_multicast --> auth.onCreateUser {"metadata":{"emulator":{"name":"functions"},"message":"Accepted multicast request POST /functions/projects/lu-echo-dev/trigger_multicast --> auth.onCreateUser"}}
[debug] [2020-10-29T18:45:35.488Z] FirebaseError: No trigger with name auth.onCreateUser {"metadata":{"emulator":{"name":"functions"},"message":{"name":"FirebaseError","children":[],"exit":1,"message":"No trigger with name auth.onCreateUser","status":500}}}
[debug] [2020-10-29T18:45:35.488Z] [work-queue] {"queueLength":0,"workRunningCount":0}
I've encountered with the same issue with below.
firebase-tools: 8.14.1
Platform: macOS 10.14.6
node: 10.20.1
/functions/index.js
const functions = require('firebase-functions');
const admin = require('firebase-admin')
admin.initializeApp()
module.exports = {
// ⭕️ Non-grouped Auth Trigger
authTrigger1: functions.auth.user().onCreate(user => {
// ... do something
}),
// ⭕️ Non-grouped Firestore Trigger
firestoreTrigger1: functions.firestore.document('some/{id}').onCreate(snap => {
// ... do something
}),
someGroup: {
// ❌ Grouped Auth Trigger
authTrigger2: functions.auth.user().onCreate(user => {
// ... do something
}),
// ⭕️ Grouped Firestore Trigger
firestoreTrigger2: functions.firestore.document('some/{id}').onCreate(snap => {
// ... do something
}),
},
}
Same as @afrittella
Same as @afrittella
Same as @afrittella
Non-grouped trigger functions and a grouped Firestore trigger function were fired, but a grouped Auth trigger function was not fired in emulator.
[2020-10-30T08:35:27.864Z] FirebaseError: No trigger with name someGroup.authTrigger2 {"metadata":{"emulator":{"name":"functions"},"message":{"name":"FirebaseError","children":[],"exit":1,"message":"No trigger with name someGroup.authTrigger2","status":500}}}
@afrittella @miyauchiakira thank you for reporting this! Seems like a pretty clear bug, we definitely don't have any test coverage for emulating grouped triggers. I'll try to reproduce this myself and fix it.
Most helpful comment
@afrittella @miyauchiakira thank you for reporting this! Seems like a pretty clear bug, we definitely don't have any test coverage for emulating grouped triggers. I'll try to reproduce this myself and fix it.