firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 937 forks source link

Can't Run Python and Node Functions in Same Emulator #5994

Closed jelling closed 1 year ago

jelling commented 1 year ago

[REQUIRED] Environment info

firebase-tools: 12.3.1

Platform: Windows

[REQUIRED] Test case

In firebase.json, add function configuration objects for both Node and Python:

{
  "functions": [
    {
      "source": "python",
      "codebase": "default",
      "ignore": ["venv", ".git", "firebase-debug.log", "firebase-debug.*.log"]
    },
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ],
...

[REQUIRED] Steps to reproduce

Start the emulator.

[REQUIRED] Expected behavior

Both Node and Python functions are discovered and are runnable.

[REQUIRED] Actual behavior

Specific error: functions: The functions emulator is configured but there is no functions source directory. Have you run firebase init functions?

[2023-06-15T23:55:27.376Z] > 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"]
[2023-06-15T23:55:27.377Z] > authorizing via signed-in user (jon@conatus.co)
[2023-06-15T23:55:27.484Z] java version "19.0.2" 2023-01-17

[2023-06-15T23:55:27.485Z] Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)

[2023-06-15T23:55:27.499Z] Parsed Java major version: 19
i  emulators: Starting emulators: auth, functions, firestore, hosting, storage {"metadata":{"emulator":{"name":"hub"},"message":"Starting emulators: auth, functions, firestore, hosting, storage"}}
[2023-06-15T23:55:27.515Z] [logging] Logging Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-06-15T23:55:27.516Z] [auth] Authentication Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-06-15T23:55:27.516Z] [firestore] Firestore Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-06-15T23:55:27.516Z] [firestore.websocket] websocket server for firestore only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-06-15T23:55:27.517Z] [hosting] Hosting Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-06-15T23:55:27.517Z] [storage] Storage Emulator only supports listening on one address (127.0.0.1). Not listening on ::1
[2023-06-15T23:55:27.517Z] assigned listening specs for emulators {"user":{"hub":[{"address":"127.0.0.1","family":"IPv4","port":4400},{"address":"::1","family":"IPv6","port":4400}],"ui":[{"address":"127.0.0.1","family":"IPv4","port":4000},{"address":"::1","family":"IPv6","port":4000}],"logging":[{"address":"127.0.0.1","family":"IPv4","port":4500}],"auth":[{"address":"127.0.0.1","family":"IPv4","port":9099}],"firestore":[{"address":"127.0.0.1","family":"IPv4","port":8080}],"firestore.websocket":[{"address":"127.0.0.1","family":"IPv4","port":9150}],"hosting":[{"address":"127.0.0.1","family":"IPv4","port":5002}],"storage":[{"address":"127.0.0.1","family":"IPv4","port":9199}]},"metadata":{"message":"assigned listening specs for emulators"}}
[2023-06-15T23:55:27.528Z] [hub] writing locator at C:\Users\jonat\AppData\Local\Temp\hub-reboot-tv-dev.json
!  functions: The functions emulator is configured but there is no functions source directory. Have you run firebase init functions? {"metadata":{"emulator":{"name":"functions"},"message":"The functions emulator is configured but there is no functions source directory. Have you run \u001b[1mfirebase init functions\u001b[22m?"}}
[2023-06-15T23:55:27.541Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-06-15T23:55:27.541Z] Ignoring unsupported arg: single_project_mode_error {"metadata":{"emulator":{"name":"firestore"},"message":"Ignoring unsupported arg: single_project_mode_error"}}
[2023-06-15T23:55:27.542Z] Starting Firestore Emulator with command {"binary":"java","args":["-Dgoogle.cloud_firestore.debug_log_level=FINE","-Duser.language=en","-jar","C:\\Users\\jonat\\.cache\\firebase\\emulators\\cloud-firestore-emulator-v1.17.4.jar","--host","127.0.0.1","--port",8080,"--websocket_port",9150,"--project_id","reboot-tv-dev","--rules","C:\\dev\\rbt\\tv\\firestore.rules","--single_project_mode",true],"optionalArgs":["port","webchannel_port","host","rules","websocket_port","functions_emulator","seed_from_export","project_id","single_project_mode"],"joinArgs":false} {"metadata":{"emulator":{"name":"firestore"},"message":"Starting Firestore Emulator with command {\"binary\":\"java\",\"args\":[\"-Dgoogle.cloud_firestore.debug_log_level=FINE\",\"-Duser.language=en\",\"-jar\",\"C:\\\\Users\\\\jonat\\\\.cache\\\\firebase\\\\emulators\\\\cloud-firestore-emulator-v1.17.4.jar\",\"--host\",\"127.0.0.1\",\"--port\",8080,\"--websocket_port\",9150,\"--project_id\",\"reboot-tv-dev\",\"--rules\",\"C:\\\\dev\\\\rbt\\\\tv\\\\firestore.rules\",\"--single_project_mode\",true],\"optionalArgs\":[\"port\",\"webchannel_port\",\"host\",\"rules\",\"websocket_port\",\"functions_emulator\",\"seed_from_export\",\"project_id\",\"single_project_mode\"],\"joinArgs\":false}"}}
i  firestore: Firestore Emulator logging to firestore-debug.log {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator logging to \u001b[1mfirestore-debug.log\u001b[22m"}}
+  firestore: Firestore Emulator UI websocket is running on 9150. {"metadata":{"emulator":{"name":"firestore"},"message":"Firestore Emulator UI websocket is running on 9150."}}    
[2023-06-15T23:55:34.692Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"storage"},"message":"Ignoring unsupported arg: port"}}
[2023-06-15T23:55:35.430Z] Temp file directory for storage emulator: C:\Users\jonat\AppData\Local\Temp/firebase/storage/blobs {"metadata":{"emulator":{"name":"storage"},"message":"Temp file directory for storage emulator: C:\\Users\\jonat\\AppData\\Local\\Temp/firebase/storage/blobs"}}
[2023-06-15T23:55:35.438Z] > refreshing access token with scopes: []
[2023-06-15T23:55:35.440Z] >>> [apiv2][query] POST https://www.googleapis.com/oauth2/v3/token [none]
[2023-06-15T23:55:35.440Z] >>> [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-06-15T23:55:35.574Z] <<< [apiv2][status] POST https://www.googleapis.com/oauth2/v3/token 200
[2023-06-15T23:55:35.574Z] <<< [apiv2][body] POST https://www.googleapis.com/oauth2/v3/token [omitted]
[2023-06-15T23:55:35.586Z] >>> [apiv2][query] GET https://firebasehosting.googleapis.com/v1beta1/projects/reboot-tv-dev/sites
[2023-06-15T23:55:35.993Z] <<< [apiv2][status] GET https://firebasehosting.googleapis.com/v1beta1/projects/reboot-tv-dev/sites 200
[2023-06-15T23:55:35.994Z] <<< [apiv2][body] GET https://firebasehosting.googleapis.com/v1beta1/projects/reboot-tv-dev/sites {"sites":[{"name":"projects/reboot-tv-dev/sites/reboot-tv-dev","defaultUrl":"https://reboot-tv-dev.web.app","type":"DEFAULT_SITE"}]}
[2023-06-15T23:55:35.994Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/reboot-tv-dev/webApps/-/config [none]
[2023-06-15T23:55:36.375Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/reboot-tv-dev/webApps/-/config 200
[2023-06-15T23:55:36.375Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/reboot-tv-dev/webApps/-/config {"projectId":"reboot-tv-dev","storageBucket":"reboot-tv-dev.appspot.com","locationId":"us-central","apiKey":"REDACTED","authDomain":"reboot-tv-dev.firebaseapp.com","messagingSenderId":"607433265404"} 
[2023-06-15T23:55:36.379Z] >>> [apiv2][query] GET https://firebase.googleapis.com/v1beta1/projects/reboot-tv-dev [none]
[2023-06-15T23:55:36.553Z] <<< [apiv2][status] GET https://firebase.googleapis.com/v1beta1/projects/reboot-tv-dev 200
[2023-06-15T23:55:36.553Z] <<< [apiv2][body] GET https://firebase.googleapis.com/v1beta1/projects/reboot-tv-dev {"projectId":"reboot-tv-dev","projectNumber":"607433265404","displayName":"Reboot TV Dev","name":"projects/reboot-tv-dev","resources":{"hostingSite":"reboot-tv-dev","storageBucket":"reboot-tv-dev.appspot.com","locationId":"us-central"},"state":"ACTIVE","etag":"1_8529987e-3667-47e2-9e6f-4938767a48a7"}
i  hosting[reboot-tv-dev]: Serving hosting files from: build {"metadata":{"emulator":{"name":"hosting"},"message":"Serving hosting files from: \u001b[1mbuild\u001b[22m"}}
+  hosting[reboot-tv-dev]: Local server: http://127.0.0.1:5002 {"metadata":{"emulator":{"name":"hosting"},"message":"Local server: \u001b[4m\u001b[1mhttp://127.0.0.1:5002\u001b[22m\u001b[24m"}}
[2023-06-15T23:55:36.574Z] Ignoring unsupported arg: auto_download {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: auto_download"}}
[2023-06-15T23:55:36.574Z] Ignoring unsupported arg: port {"metadata":{"emulator":{"name":"ui"},"message":"Ignoring unsupported arg: port"}}
[2023-06-15T23:55:36.575Z] Starting Emulator UI with command {"binary":"node","args":["C:\\Users\\jonat\\.cache\\firebase\\emulators\\ui-v1.11.6\\server\\server.js"],"optionalArgs":[],"joinArgs":false} {"metadata":{"emulator":{"name":"ui"},"message":"Starting Emulator UI with command {\"binary\":\"node\",\"args\":[\"C:\\\\Users\\\\jonat\\\\.cache\\\\firebase\\\\emulators\\\\ui-v1.11.6\\\\server\\\\server.js\"],\"opti[2023-06-15T23:55:36.700Z] Web / API server started at 127.0.0.1:4000
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at 127.0.0.1:4000\n"}}
[2023-06-15T23:55:36.700Z] Web / API server started at ::1:4000
 {"metadata":{"emulator":{"name":"ui"},"message":"Web / API server started at ::1:4000\n"}}

┌─────────────────────────────────────────────────────────────┐
│ ✔  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      │ Failed to initialize (see above) │                                 │
├────────────────┼──────────────────────────────────┼─────────────────────────────────┤
│ Firestore      │ 127.0.0.1:8080                   │ http://127.0.0.1:4000/firestore │
├────────────────┼──────────────────────────────────┼─────────────────────────────────┤
│ Hosting        │ 127.0.0.1:5002                   │ n/a                             │
├────────────────┼──────────────────────────────────┼─────────────────────────────────┤
│ Storage        │ 127.0.0.1:9199                   │ http://127.0.0.1:4000/storage   │
└────────────────┴──────────────────────────────────┴─────────────────────────────────┘
  Emulator Hub running at 127.0.0.1:4400
  Other reserved ports: 4500, 9150

Issues? Report them at https://github.com/firebase/firebase-tools/issues and attach the *-debug.log files.
aalej commented 1 year ago

Hi @jelling, thanks for reaching out to us. I’m able to reproduce the issue you mentioned.

One thing I noticed is that you have the same codebase name for both Node and Python. I'm thinking this might be causing the issue as the value of each functions codebase must be unique. Could you try changing one of the codebase names?

I was able to initialize both Javascript and Python functions on the emulator using the following configuration in my firebase.json file:

{
  "functions": [
    {
      "source": "functions",
      "codebase": "default",
      "ignore": [
        "node_modules",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    },
    {
      "source": "python",
      "codebase": "python-default",
      "ignore": [
        "venv",
        ".git",
        "firebase-debug.log",
        "firebase-debug.*.log"
      ]
    }
  ]
}

If the issue persists after updating the codebase names, could you provide more details on how you set up your functions, and if possible, also share an overview of your project directory which contains the functions?

joehan commented 1 year ago

Resolving this since @aalej identified the issue - please comment if youre still having issues after fixing the codebase name collision

zouhirdev commented 3 months ago

Hello, im currently developing a flutter app using firebase functions im using python but it doesnt support authentication triggers so i need to use javascript alog with python can you explain how did you do that. im not an expert but i dont think it gonna be hard. thanks in advence