I am building an extension by reading this official documentation and getting error in 4 step, while start emulator in firebase extension firebase emulators:start --project=demo-test
.
Error :
C:UsersRAJENDRA A VERMADesktopFirebase Extensionrtdb-uppercase-
messagesfunctionsintegration-tests>firebase emulators:start --project=demo-test
i emulators: Starting emulators: functions, database, extensions
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 emulators: Shutting down emulators.
Error: An unexpected error has occurred.
error in firebase-debug.log
[debug] [2023-08-16T15:34:36.952Z] ----------------------------------------------------------------------
[debug] [2023-08-16T15:34:36.955Z] Command: C:Program Filesnodejsnode.exe C:UsersRAJENDRA A VERMAAppDataRoamingnpmnode_modulesfirebase-toolslibbinfirebase.js emulators:start --project=demo-test
[debug] [2023-08-16T15:34:36.956Z] CLI Version: 12.4.8
[debug] [2023-08-16T15:34:36.956Z] Platform: win32
[debug] [2023-08-16T15:34:36.957Z] Node Version: v18.16.0
[debug] [2023-08-16T15:34:36.968Z] Time: Wed Aug 16 2023 21:04:36 GMT+0530 (India Standard Time)
[debug] [2023-08-16T15:34:36.969Z] ----------------------------------------------------------------------
[debug]
[debug] [2023-08-16T15:34:37.137Z] Object ".extensions" in "firebase.json" has unknown property: {"additionalProperty":"rtdb-uppercase-messages"}
[debug] [2023-08-16T15:34:37.147Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2023-08-16T15:34:37.147Z] > authorizing via signed-in user ([email protected])
[debug] [2023-08-16T15:34:37.333Z] java version "20.0.1" 2023-04-18
[debug] [2023-08-16T15:34:37.334Z] Java(TM) SE Runtime Environment (build 20.0.1+9-29)
Java HotSpot(TM) 64-Bit Server VM (build 20.0.1+9-29, mixed mode, sharing)
[debug] [2023-08-16T15:34:37.390Z] Parsed Java major version: 20
[info] i emulators: Starting emulators: functions, database, extensions {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: functions, database, extensions"}}
[info] 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. {"metadata":{"emulator":{"name":"hub"},"message":"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."}}
[debug] [2023-08-16T15:34:37.398Z] Successfully read params from rtdb-uppercase-messages.env
[debug] [2023-08-16T15:34:37.399Z] Error: ENOENT: no such file or directory, open 'C:UsersRAJENDRA A VERMADesktopFirebase Extensionrtdb-uppercase-messagesfunctionsintegration-testsextensionsrtdb-uppercase-messages.env.0'
[debug] [2023-08-16T15:34:37.399Z] Error: ENOENT: no such file or directory, open 'C:UsersRAJENDRA A VERMADesktopFirebase Extensionrtdb-uppercase-messagesfunctionsintegration-testsextensionsrtdb-uppercase-messages.env.demo-test'
[debug] [2023-08-16T15:34:37.400Z] Error: ENOENT: no such file or directory, open 'C:UsersRAJENDRA A VERMADesktopFirebase Extensionrtdb-uppercase-messagesfunctionsintegration-testsextensionsrtdb-uppercase-messages.env.local'
[debug] [2023-08-16T15:34:37.419Z] [extensions] Source code valid for ../..
[info] i emulators: Shutting down emulators. {"metadata":{"emulator":{"name":"hub"},"message":"Shutting down emulators."}}
[debug] [2023-08-16T15:34:37.624Z] TypeError: Cannot read properties of undefined (reading 'filter')
at getNonSecretEnv (C:UsersRAJENDRA A VERMAAppDataRoamingnpmnode_modulesfirebase-toolslibextensionsemulatoroptionsHelper.js:62:33)
at getExtensionFunctionInfo (C:UsersRAJENDRA A VERMAAppDataRoamingnpmnode_modulesfirebase-toolslibextensionsemulatoroptionsHelper.js:49:26)
at async ExtensionsEmulator.toEmulatableBackend (C:UsersRAJENDRA A VERMAAppDataRoamingnpmnode_modulesfirebase-toolslibemulatorextensionsEmulator.js:146:82)
at async Promise.all (index 0)
at async ExtensionsEmulator.getExtensionBackends (C:UsersRAJENDRA A VERMAAppDataRoamingnpmnode_modulesfirebase-toolslibemulatorextensionsEmulator.js:137:25)
at async Object.startAll (C:UsersRAJENDRA A VERMAAppDataRoamingnpmnode_modulesfirebase-toolslibemulatorcontroller.js:209:36)
at async C:UsersRAJENDRA A VERMAAppDataRoamingnpmnode_modulesfirebase-toolslibcommandsemulators-start.js:32:43
[error]
[error] Error: An unexpected error has occurred.
file structure
:
rtdb-uppercase-messages
├── functions
│ ├── integration-tests
│ │ ├── extensions
│ │ │ └── rtdb-uppercase-messages.env
│ │ ├── .firebaserc
│ │ ├── firebase.json
│ │ └── integration-test.spec.js
│ ├── node_modules
│ ├── index.js
│ ├── package-lock.json
│ └── package.json
├── README.md
├── PREINSTALL.md
├── POSTINSTALL.md
├── CHANGELOG.md
└── extension.yaml
in extension.yaml
:
name: rtdb-uppercase-messages
version: 0.0.1
specVersion: v1beta # Firebase Extensions specification version; don't change
# Friendly display name for your extension (~3-5 words)
displayName: Convert messages to upper case
# Brief description of the task your extension performs (~1 sentence)
description: >-
Converts messages in RTDB to upper case
author:
authorName: Your Name
url: https://your-site.example.com
license: Apache-2.0 # Required license
# Public URL for the source code of your extension
sourceUrl: https://github.com/your-name/your-repo
resources:
- name: makeuppercase
type: firebaseextensions.v1beta.function
properties:
eventTrigger:
eventType: providers/google.firebase.database/eventTypes/ref.create
# DATABASE_INSTANCE (project's default instance) is an auto-populated
# parameter value. You can also specify an instance.
resource: projects/_/instances/${DATABASE_INSTANCE}/refs/messages/{pushId}/original
runtime: "nodejs18"
in firebase.json
:
{
"emulators": {
"functions": {
"port": 5001
},
"ui": {
"enabled": true
},
"singleProjectMode": true,
"database": {
"port": 9000
}
},
"extensions": {
"rtdb-uppercase-messages": "../.."
}
}
Where is the mistake happening? Where am I making a mistake?
2
Answers
You could try the following:
Check the firebase-debug.log file that should now be in your directory to see if there any more details on the error.
If you are using node18, this can cause issues with the emulator. You can ensure that functions has a non localhost reference.
For example:
firebaser here
Sorry to hear that you ran into this – This looks like a bug with the Extensions emulator. I’ve opened https://github.com/firebase/firebase-tools/issues/6271 describing more details about what’s happening & should have a fix out in the next release for firebase-tools.
For now, the workaround is to add a
params
section to the top level of yourextension.yaml
. It can even be empty, i.e.: